You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have asked this question before in Scanpy, but I wasn't sure I made it clear. So I'm giving it a try again:
Say I have the PBMC 3K dataset, and after clustering and DEG in Scanpy, I have 120 genes specific for cluster 1 and 80 genes specific for cluster 3. Now, what I would like is to take these 200 genes and export them as an expression matrix (csv or tab), where rownames are the gene symbols (i.e: IFNG, IL10, etc) and colnames are the cell ids (barcodes) present within each cluster.
How do I get this from an h5ad file?
Thanks!
The text was updated successfully, but these errors were encountered:
cartal
changed the title
Subset expression matrix from custom genes
QUESTION: Subset expression matrix from custom genes
Dec 26, 2018
Obviously, you'd need to subset the anndata object before:
import scanpy.api as sc
adata = sc.datasets.pbmc68k_reduced()
# this writes everything, the data matrix and annotations end up in separate files
adata[:, ['HES4', 'TNFRSF4', 'SSU72']].copy().write_csvs('./test/', skip_data=False)
# this writes only the data matrix
adata[:, ['HES4', 'TNFRSF4', 'SSU72']].to_df().to_csv('./matrix.csv')
Hope this helps!
PS: Please, next time reference your previous issue. Also, provide a small example such as the one above.
Hi,
I have asked this question before in Scanpy, but I wasn't sure I made it clear. So I'm giving it a try again:
Say I have the PBMC 3K dataset, and after clustering and DEG in Scanpy, I have 120 genes specific for cluster 1 and 80 genes specific for cluster 3. Now, what I would like is to take these 200 genes and export them as an expression matrix (csv or tab), where rownames are the gene symbols (i.e: IFNG, IL10, etc) and colnames are the cell ids (barcodes) present within each cluster.
How do I get this from an h5ad file?
Thanks!
The text was updated successfully, but these errors were encountered: