scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.93k stars 603 forks source link

Can't read in protein antibody capture data #3113

Open alexanderchang1 opened 5 months ago

alexanderchang1 commented 5 months ago

Please make sure these conditions are met

What happened?

I'm trying to read in visium data with antibody capture data but for some reason the antibody capture data is not registering. Is there something I'm doing wrong? I couldn't find documentation on how to do this. Although I do see the antibody capture data in the web_summary.html

However read_10x_mtx method works directly on the folder, is there a way to add gex_only functionality to the read_visium function?

Minimal code sample

print(key)
        adata = sc.read_visium(path, count_file='filtered_feature_bc_matrix.h5', load_images=True, )
        print(adata)

        # Separate RNA and protein data
        rna_data = adata[:, adata.var['feature_types'] == 'Gene Expression']
        protein_data = adata[:, adata.var['feature_types'] == 'Antibody Capture']

        # Verify the separated data
        print("RNA data shape:", rna_data.shape)
        print("Protein data shape:", protein_data.shape)

Error output

MWS22-14789

AnnData object with n_obs × n_vars = 2256 × 18085
    obs: 'in_tissue', 'array_row', 'array_col'
    var: 'gene_ids', 'feature_types', 'genome', 'isotype_control', 'normalized', 'pattern', 'read', 'secondary_name', 'sequence'
    uns: 'spatial'
    obsm: 'spatial'
RNA data shape: (2256, 18085)
Protein data shape: (2256, 0)

Versions

``` 1.10.1 ```
alexanderchang1 commented 4 months ago

Hi, I just wanted to follow up on this.

flying-sheep commented 3 months ago

Hi, I don’t have much experience with that data. Does squidpy work better? https://squidpy.readthedocs.io/en/stable/api/squidpy.read.visium.html

scanpy doesn’t have much support for spatial analysis, squidpy is built for it.

alexanderchang1 commented 1 month ago

Hi, let me give that a shot.

alexanderchang1 commented 1 month ago

Hi, I tried that and got this error. I think it's because it's recognizing both antibody data and gene data and throwing an error.


TypeError Traceback (most recent call last) Cell In[7], line 13 11 key = get_second_to_last_split(path) 12 print(key) ---> 13 adata = sq.read.visium(path, count_file='filtered_feature_bc_matrix.h5', load_images=True) 15 # Create unique cell identifiers 16 adata.obsnames = f'sample{key}_' + adata.obs_names

File /bgfs/alee/LO_LAB/Personal/Alexander_Chang/alc376/envs/popari_env/lib/python3.12/site-packages/squidpy/read/_read.py:67, in visium(path, counts_file, library_id, load_images, source_image_path, kwargs) 34 """ 35 Read 10x Genomics Visium formatted dataset. 36 (...) 64 - :attr:anndata.AnnData.uns ['spatial']['{library_id}']['metadata'] - various metadata. 65 """ # noqa: E501 66 path = Path(path) ---> 67 adata, library_id = _read_counts(path, count_file=counts_file, library_id=library_id, kwargs) 69 if not load_images: 70 return adata

TypeError: squidpy.read._utils._read_counts() got multiple values for keyword argument 'count_file'