Files for embedding data type
Import packages
import scanpy as sc
import pandas as pd
Step 1
Read the .mtx file using scanpy.read_mtx which will result in an anndata file (that can be written to .h5ad)
Sample Matrix file
%%MatrixMarket matrix coordinate integer general
%
90980 20242 42994070
1 9114 1
1 14115 1
1 17826 1
adata = sc.read_mtx("/home/ubuntu/matrix.mtx")
Step 2
Sample metadata file
cell,cluster
D062_AACGAGAGCTAAACCTAAGTGG,Lymphatics
D062_AACGAGAGCTAAACTAGCCCTA,Capillary 1
D062_AACGAGAGCTAAAGGAACAGAC,Macrophages
Reading the metadata in using using the pandas function
adata.obs = pd.read_csv("/home/ubuntu/meta.csv")
Step 3
Sample UMAP coordinate file
UMAP1,UMAP2
23399.000000,30703.000000
36861.000000,61648.000000
48900.000000,32121.000000
embeddings = pd.read_csv("/home/ubuntu/UMAP_coordinates.coords.csv")
embeddings = embeddings.to_numpy()
adata.obsm["X_umap"] = embeddings
Step 4
Writing h5ad output
adata.write("./atac.h5ad")