Last active
April 16, 2020 00:52
-
-
Save Xparx/eaaa4a4615dc3f37d6bc962019be1a05 to your computer and use it in GitHub Desktop.
This file contains 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
import scanpy as sc | |
import pandas as pd | |
data = pd.read_csv('path_to_file.csv') | |
feature_annotations = pd.read_csv('path_to_annotations.csv') | |
# Make sure samples are rows and features are columns. if not data = data.T | |
adata = sc.AnnData(data, obs=sample_names, var=feature_annotations) | |
sc.pp.pca(adata, n_comps=10) | |
sc.pp.neighbors(adata, n_neighbors = 10, n_pcs = 10) |
This file contains 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
import matplotlib.pyplot as plt | |
fig, ax = dewaxer.plot_global_performance() | |
fig.savefig('global_performance.svg', format='svg') | |
fig, ax = dewaxer.plot_local_performance() | |
fig.savefig('local_performance.svg', format='svg') | |
fig = plt.figure(figsize=(6,4), constrained_layout=True) | |
ax = fig.subplots(1, 1) | |
sc.pl.embedding(ddata, basis='umap', color='leiden', edges=True, ax=ax) | |
fig.savefig('embedding_clusters.svg', format='svg') |
This file contains 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
from dewakss import denoise as dewakss | |
# Load data: | |
# Rin dewakss | |
neigbours = list(range(3,10)) | |
npcss = list(range(3,10)) | |
dewaxer = dewakss.DEWAKSS(adata, n_neighbors=neigbours, n_pcs=npcss, use_global_err=False) | |
dewaxer.fit(adata) | |
ddata = dewaxer.transform(adata, copy=True) | |
sc.tl.leiden(ddata, resolution = 1) | |
sc.tl.umap(ddata, min_dist = 0.01) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment