@classmethod<EOL><INDENT>def read_10xgenomics(cls, tarball_fpath: str, prefix: str,<EOL>use_ensembl_ids: bool = False):<DEDENT>
_LOGGER.info('<STR_LIT>', tarball_fpath)<EOL>with tarfile.open(tarball_fpath, mode='<STR_LIT>') as tf:<EOL><INDENT>ti = tf.getmember('<STR_LIT>' % prefix)<EOL>with tf.extractfile(ti) as fh:<EOL><INDENT>mtx = scipy.io.mmread(fh)<EOL><DEDENT>ti = tf.getmember('<STR_LIT>' % prefix)<EOL>with tf.extractfile(ti) as fh:<EOL><INDENT>wrapper = io.TextIOWrapper(fh, encoding='<STR_LIT:ascii>')<EOL>i = <NUM_LIT:1><EOL>if use_ensembl_ids:<EOL><INDENT>i = <NUM_LIT:0><EOL><DEDENT>gene_names =[row[i] for row in csv.reader(wrapper, delimiter='<STR_LIT:\t>')]<EOL><DEDENT>ti = tf.getmember('<STR_LIT>' % prefix)<EOL>with tf.extractfile(ti) as fh:<EOL><INDENT>wrapper = io.TextIOWrapper(fh, encoding='<STR_LIT:ascii>')<EOL>barcodes =[row[<NUM_LIT:0>] for row in csv.reader(wrapper, delimiter='<STR_LIT:\t>')]<EOL><DEDENT>assert mtx.shape[<NUM_LIT:0>] == len(gene_names)<EOL>assert mtx.shape[<NUM_LIT:1>] == len(barcodes)<EOL><DEDENT>_LOGGER.info('<STR_LIT>', str(mtx.shape))<EOL>X = mtx.todense()<EOL>matrix = cls(X=X, genes=gene_names, cells=barcodes)<EOL>return matrix<EOL>
Read a 10X genomics compressed tarball containing expression data.

        Note: common prefix patterns:
        - "filtered_gene_bc_matrices/[annotations]/"
        - "filtered_matrices_mex/[annotations]/"

        TODO: docstring