raw_to_mtx

besca.export.raw_to_mtx(adata: AnnData, outpath: str = '/Users/kohlem13/projects/besca/docs/source', write_metadata: bool = False, geneannotation: str = 'ENSEMBL', additional_geneannotation: Optional[str] = None) None[source]

export adata.raw to .mtx (matrix.mtx, genes.tsv, barcodes, tsv)

exports the counts contained in adata.raw.X to a matrix.mtx file (in sparse format), genes taken from adata.raw.var_names to genes.tsv and the cellbarcodes from adata.obs_names to barcodes.tsv. If annotation = True, then the entire pd.Dataframe contained in adata.obs is in addition exported to metadata.tsv.

Through the parameter genetannotation you can specify which type of geneidentifer is saved in adata.raw.var_names. You can pass an additional string to the parameter additional_geneannotation which specifies under which column name in adata.raw.var an additional geneannotation can be found. Currently this function is only capable of dealing with geneannotation of the type ENSEMBL or SYMBOL. This feature is intended to conserve the correct order of ENSEMBL IDs and SYMBOL symbols in the genes.tsv file.

If the outpath directory does not exist, this function automatically generates it.

Parameters:
  • adata (AnnData) – the AnnData object which raw that should be exported

  • directory (outpath str | default = current working) – filepath to the directory in which the results should be outputed, if no directory is specified it outputs the results to the current working directory.

  • write_metadata (bool | default = False) – boolian indicator if the annotation contained in adata.obs should be exported as well

  • geneannotation (‘ENSEMBL or ‘SYMBOL) – string indicator of the type of gene annotation saved in adata.var_names

  • additional_geneannotation (str | default = None) – string identifying the coloumn name in which either the SYMBOL symbols or the ENSEMBL geneids are contained as additional gene annotation in adata.var

Returns:

writes out files to the specified output directory

Return type:

None