Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when packing anndata object? #54

Open
cameronyoungpark opened this issue May 24, 2023 · 0 comments
Open

Error when packing anndata object? #54

cameronyoungpark opened this issue May 24, 2023 · 0 comments

Comments

@cameronyoungpark
Copy link

Hello,
I am trying to run mnnpy.mnn_correct on 2 anndata objects. The code works until the last step of packing AnnData and I get the error: AttributeError: Can only use .str accessor with string values!

Here is the output from the function:

Performing cosine normalization...
Starting MNN correct iteration. Reference batch: 0
Step 1 of 1: processing batch 1
  Looking for MNNs...
  Computing correction vectors...
  Adjusting variance...
  Applying correction...
MNN correction complete. Gathering output...
Packing AnnData object...
/home/cyp2111_columbia_edu/anaconda3/lib/python3.8/site-packages/anndata/_core/anndata.py:1755: FutureWarning: The AnnData.concatenate method is deprecated in favour of the anndata.concat function. Please use anndata.concat instead.

See the tutorial for concat at: https://anndata.readthedocs.io/en/latest/concatenation.html
  warnings.warn(
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-f5b1f9f9bdff> in <module>
      2 import mnnpy
      3 
----> 4 corrected = mnnpy.mnn_correct(ad21, ad20)
      5 adata = corrected[0]

~/anaconda3/lib/python3.8/site-packages/mnnpy/mnn.py in mnn_correct(var_index, var_subset, batch_key, index_unique, batch_categories, k, sigma, cos_norm_in, cos_norm_out, svd_dim, var_adj, compute_angle, mnn_order, svd_mode, do_concatenate, save_raw, n_jobs, *datas, **kwargs)
    127         print('Packing AnnData object...')
    128         if do_concatenate:
--> 129             adata = AnnData.concatenate(*datas, batch_key=batch_key,
    130                                         batch_categories=batch_categories,
    131                                         index_unique=index_unique)

~/anaconda3/lib/python3.8/site-packages/anndata/_core/anndata.py in concatenate(self, join, batch_key, batch_categories, uns_merge, index_unique, fill_value, *adatas)
   1806             :,
   1807             (
-> 1808                 out.var.columns.str.extract(pat, expand=False)
   1809                 .fillna("")
   1810                 .argsort(kind="stable")

~/anaconda3/lib/python3.8/site-packages/pandas/core/accessor.py in __get__(self, obj, cls)
    222             # we're accessing the attribute of the class, i.e., Dataset.geo
    223             return self._accessor
--> 224         accessor_obj = self._accessor(obj)
    225         # Replace the property with the accessor object. Inspired by:
    226         # https://www.pydanny.com/cached-property.html

~/anaconda3/lib/python3.8/site-packages/pandas/core/strings/accessor.py in __init__(self, data)
    179         from pandas.core.arrays.string_ import StringDtype
    180 
--> 181         self._inferred_dtype = self._validate(data)
    182         self._is_categorical = is_categorical_dtype(data.dtype)
    183         self._is_string = isinstance(data.dtype, StringDtype)

~/anaconda3/lib/python3.8/site-packages/pandas/core/strings/accessor.py in _validate(data)
    233 
    234         if inferred_dtype not in allowed_types:
--> 235             raise AttributeError("Can only use .str accessor with string values!")
    236         return inferred_dtype
    237 

AttributeError: Can only use .str accessor with string values!

Has anyone encountered this and if so, does anyone know how I can fix this? The datatypes of the obs and vars in the individual anndata objects are strings, so do not know what this is referring to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant