Scanpy 10x Implementation
mbcouger opened this issue · comments
Hello,
I am trying to use infercnvpy with a 10x dataset. Assuming I follow the tutorial for 10x data and end up with leiden clusters, what would be the commands nescarry to run these on each leiden cluster. This was my best guess which did not work, I beleive I am confused by the syntax.
cnv.pl.chromosome_heatmap(adata, groupby="leiden")
infercnvpy.io.genomic_position_from_gtf('./genes.gtf', adata=None, gtf_gene_id='gene_id', adata_gene_id=None, inplace=True)
What would be the proper way to do this?
Many Thanks!
ErrorLog:
AnnData object with n_obs × n_vars = 30975 × 2886
obs: 'n_genes', 'n_genes_by_counts', 'total_counts', 'total_counts_mt', 'pct_counts_mt', 'leiden'
var: 'gene_ids', 'feature_types', 'n_cells', 'mt', 'n_cells_by_counts', 'mean_counts', 'pct_dropout_by_counts', 'total_counts', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std'
uns: 'hvg', 'leiden', 'leiden_colors', 'neighbors', 'pca', 'rank_genes_groups', 'umap'
obsm: 'X_pca', 'X_umap'
varm: 'PCs'
obsp: 'connectivities', 'distances'
cnv.pl.chromosome_heatmap(adata, groupby="leiden")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-67-f452572c6524> in <module>
----> 1 cnv.pl.chromosome_heatmap(adata, groupby="leiden")
~/anaconda3/lib/python3.8/site-packages/infercnvpy/pl/_chromosome_heatmap.py in chromosome_heatmap(adata, groupby, use_rep, cmap, figsize, show, save, **kwargs)
56 "'cnv_leiden' is not in `adata.obs`. Did you run `tl.leiden()`?"
57 )
---> 58 tmp_adata = AnnData(X=adata.obsm["X_cnv"], obs=adata.obs)
59 chr_pos = list(adata.uns[use_rep]["chr_pos"].values())
60
~/anaconda3/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in __getitem__(self, key)
146
147 def __getitem__(self, key: str) -> V:
--> 148 return self._data[key]
149
150 def __setitem__(self, key: str, value: V):
KeyError: 'X_cnv'
infercnvpy.io.genomic_position_from_gtf('./genes.gtf', adata=None, gtf_gene_id='gene_id', adata_gene_id=None, inplace=True)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-69-e28d9c88fbac> in <module>
----> 1 infercnvpy.io.genomic_position_from_gtf('./genes.gtf', adata=None, gtf_gene_id='gene_id', adata_gene_id=None, inplace=True)
Hi @mbcouger
I think the problem is that you need to run genomic_position_from_gtf
first, then tl.infercnv
before you can plot anything.
Also you have adata=None
for genomic_position_from_gtf
, but you need to specify the same AnnData
object there you use for the other functions.
Best,
Gregor
Hi Gregor,
Thank you I caught this but still have a question on implementation
suppose my gtf is name (genes.gft) What would the command to run
infercnvpy.io.genomic_position_from_gtf('./genes.gtf', adata=None, gtf_gene_id='gene_id', adata_gene_id=None, inplace=True)
I get "name error"
Also if I run the 10x scanpy and get Lendian Clusters, is there a way I can run ithe infercnvpy on a specific cluster?
Many, many thanks for the help!
Cheers,
Brian
infercnvpy.io.genomic_position_from_gtf('./genes.gtf', adata=None, gtf_gene_id='gene_id', adata_gene_id=None, inplace=True)
I get "name error"
You still have adata=None
here. You need to specify an actual AnnData
object.
Also if I run the 10x scanpy and get Lendian Clusters, is there a way I can run ithe infercnvpy on a specific cluster?
You can simply subset adata
:
adata = adata[adata.obs["leiden"] == "42", :].copy()
I think this has been solved. Feel free to open a new issue if there are other problems.