AG projects

import pegasus as pg import scanpy as sc import pandas as pd import matplotlib.colors as clr import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import seaborn as sns # Set a colormap colormap = clr.LinearSegmentedColormap.from_list('gene_cmap', ["#e0e0e1", '#4576b8', '#02024a'], N=200) # Aggregate the matrices pg.aggregate_matrices(csv_file = "/home/nealpsmith/projects/medoff/cellranger/aggregate_matrix.csv", what_to_return = "/home/nealpsmith/projects/medoff/data/all_data.h5sc") all_data = pg.read_input("/home/nealpsmith/projects/medoff/data/all_data.h5sc") pg.qc_metrics(all_data, percent_mito = 30) # Plot the percent mito/n genes # fig, ax = plt.subplots(1) # x = all_data.obs["n_genes"] # y = all_data.obs["percent_mito"] # _ = ax.hexbin(x, y, mincnt=1, xscale = "log") # _ = ax.set_xticks([10, 100, 1000]) # _ = ax.get_xaxis().set_major_formatter(mpl.ticker.ScalarFormatter()) # _ = ax.axvline(500, color="red") # _ = ax.axhline(30, color="red") # _ = plt.xlabel("Number of genes") # _ = plt.ylabel("percent mitochondrial UMIs") violin_dat = all_data.obs[["Channel", "percent_mito"]] violin_dat[["Channel"]] = [n.replace("ANA", "AC") for n in violin_dat["Channel"]] violin_dat[["Channel"]] = [n.replace("Pre", "Bln") for n in violin_dat["Channel"]] violin_order = ['500008_AC_Bln', '500008_AC_Dil', '500008_AC_Ag', '500012_AC_Bln', '500012_AC_Dil', '500012_AC_Ag', '500015_AC_Bln', '500015_AC_Ag', '500024_AC_Bln', '500024_AC_Dil', '500024_AC_Ag', '500021_AA_Bln', '500021_AA_Dil', '500021_AA_Ag', '500030_AA_Bln', '500030_AA_Dil', '500030_AA_Ag', '500032_AA_Bln', '500032_AA_Ag', '500035_AA_Bln', '500035_AA_Ag'] fig, ax = plt.subplots(1) sns.violinplot(x = "Channel", y = "percent_mito", color = "grey", data = violin_dat, inner = None, scale = "width", ax = ax, cut = 0, order = violin_order) for violin in ax.collections: violin.set_alpha(0.8) _ = ax.axhline(y = 30, color = "red", ls = "--") labs = ax.get_xticklabels() _ = ax.set_xticklabels(labs, rotation=90) _ = ax.set_ylabel("% mitochondrial UMIs") figure = plt.gcf() figure.set_size_inches(4, 3) figure.tight_layout() figure 我已经配置了python环境,我可以在Rstudio中运行这段代码吗
最新发布
09-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值