Marker-gene-guided dimensionality reduction (GDR)
GDR: marker Gene-guided Dimensionality Reduction
import scanpy as scimport osfrom matplotlib import rcParamsimport timeimport warningswarnings.simplefilter(action='ignore', category=FutureWarning)import piasoimport cosgsc.set_figure_params(dpi=96,dpi_save=300, color_map='viridis',facecolor='white')rcParams['figure.figsize'] = 4, 4rcParams['font.sans-serif'] = "Arial"rcParams['font.family'] = "Arial"sc.settings.verbosity = 3sc.logging.print_header()Load the data
We will be using a Multiome RNA dataset obtained from cortex at P57.
adata = piaso.data.load_dataset("adult_cortex_multiome_rna")adataadata.X=adata.layers['log1p'].copy()INFOG normalization
%%timepiaso.tl.infog(adata, layer='raw', n_top_genes=3000,)Visualize with PCA-based UMAP
First, we will use a standard PCA-based UMAP to visualize the batches and cell types in the dataset. This helps in assessing the presence of batch effects.
sc.pp.neighbors(adata, use_rep='X_pca', n_neighbors=15, random_state=10, knn=True, method="umap")
sc.tl.umap(adata)
sc.pl.umap(adata, color=['Sample','CellTypes'], palette=piaso.pl.color.d_color4, cmap=piaso.pl.color.c_color4, size=10, ncols=1, frameon=False)
The UMAP plot clearly shows batch effects in the dataset.
Dimensionality reduction with GDRParallel
In this turorial we will show how GDR works when only batch information is available and clusters or cell type informations isn’t available. In this case, runGDR clusters the data and infers the groups.
%%timepiaso.tl.runGDRParallel(adata, batch_key='Sample', groupby=None, n_gene=20, mu=10, resolution=3.0, layer='infog', infog_layer='raw', score_layer='infog', scoring_method='piaso', use_highly_variable=True, n_highly_variable_genes=5000, n_svd_dims=50, key_added='X_gdr', max_workers=32, calculate_score_multiBatch=False, verbosity=0)Visualize GDR results with UMAPs
%%timesc.pp.neighbors(adata, use_rep='X_gdr', n_neighbors=15, random_state=10, knn=True, method="umap")sc.tl.umap(adata)sc.pl.umap(adata, color=['Sample','CellTypes'], palette=piaso.pl.color.d_color4, cmap=piaso.pl.color.c_color4, size=10, ncols=1, frameon=False)
GDR effectively integrates batches and separates cell types using only dimensionality reduction, without additional integration methods.