Skip to content

extracting spliced/unspliced matrix from annData object #483

Answered by WeilerP
eynullazada asked this question in Q&A
Discussion options

You must be logged in to vote

@eynullazada, you could do the following

import pandas as pd

unspliced_df = pd.DataFrame(adata.layers['unspliced'], index=adata.obs_names, columns=adata.var_names)
unspliced_df.to_csv(PATH_TO_DATA / 'unspliced.csv')

spliced_df = pd.DataFrame(adata.layers['spliced'], index=adata.obs_names, columns=adata.var_names)
spliced_df.to_csv(PATH_TO_DATA / 'spliced.csv')

If your AnnData is loaded and PATH_TO_DATA is defined as a pathlib.Path pointing to the directory where your CSV files are to be saved, the code snipped should run as is.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@eynullazada
Comment options

@eynullazada
Comment options

@WeilerP
Comment options

@eynullazada
Comment options

Answer selected by WeilerP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #482 on June 02, 2021 05:21.