Created
February 12, 2019 22:32
-
-
Save azkalot1/af65d36d3b28b723506a769f5f931934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#reading 10X data as stated at support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices | |
matrix_dir = "filtered_feature_bc_matrix" | |
mat = scipy.io.mmread(os.path.join(matrix_dir, "matrix.mtx")) | |
mat = np.array(mat.todense()) | |
features_path = os.path.join(matrix_dir, "features.tsv") | |
annotation = pd.read_csv(features_path,sep='\t',header=None) | |
annotation.columns = ['feature_ids','gene_names','feature_types'] | |
barcodes_path = os.path.join(matrix_dir, "barcodes.tsv") | |
barcodes = [line.strip() for line in open(barcodes_path, 'r')] | |
print('Matrix dimensionality {}'.format(mat.shape)) | |
mat = mat.T #becase we want (samples,features) matrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment