weitrix
是万事通。这个描述演示了使用weitrix
比例数据。困难之一是,当一个比例是完全零方差应完全零,导致无限重量。为了解决这个问题,我们稍微夸大的估计方差的比例接近于零。这不是完美,但校准情节让我们与我们的眼睛睁开,并提供保证它不会大大干扰下游分析。
我们看GSE99970SLAM-Seq实验。在SLAM-Seq一部分尿嘧啶取代4-thiouridine (s4U)在转录过程中,一些聪明的化学导致“T”成为“C”年代合成RNA-Seq读取。的比例转换成“T”s的比例s4U应用时产生的新记录。在这个实验中小鼠胚胎干细胞受到s4U 24小时,然后洗掉,在不同时间点取样。实验让我们追踪记录的衰减率。
库(tidyverse)图书馆(ComplexHeatmap)图书馆(weitrix) # BiocParallel支持多个后端。#如果默认挂起或错误,试着别人。#最可靠的支持是使用串行处理BiocParallel::注册(BiocParallel: SerialParam ())
这是数量的利益比例的“T”转化为“C”年代。我们加载覆盖率和转换,计算这个比率。
作为一个初始权重,我们使用报道。理论上,每个平均比例这么多1和0。值平均越多,这是更准确的。
< -系统覆盖。文件(“GSE99970”、“GSE99970_T_coverage.csv。广州”,包= " weitrix ") % > % read_csv () % > % column_to_rownames(“基因”)% > % as.matrix()转换< -系统。文件(“GSE99970”、“GSE99970_T_C_conversions.csv。广州”,包= " weitrix ") % > % read_csv () % > % column_to_rownames(“基因”)% > % as.matrix() #计算比例,创造weitrix魏< - as_weitrix(转换/报道,报道)暗(魏)
# # 22281 27 [1]
#我们只会使用基因至少30转换观察好< - rowSums(转换)> = 30魏魏< -[,]#添加一些列的数据名称部分< - str_match (colnames(魏)”(. *)_ (Rep_。*)”) colData(魏)元组< - fct_inorder(部分[2])colData(魏)美元代表< - fct_inorder (paste0 (“Rep_”,部分[3]))rowData(魏)美元mean_coverage < - rowMeans (weitrix_weights(魏))
# #类:SummarizedExperiment # #暗淡:11059(1):27 # #元数据weitrix # #化验(2):x重量# # rownames (11059): 0610005 c13rik 0610007 p14rik……Zzef1 Zzz3构成了rowData名称(1):# # # # mean_coverage colnames (27): no_s4U_Rep_1 no_s4U_Rep_2……24 h_chase_rep_2 24 h_chase_rep_3 # # # # colData名称(2):小组代表
colMeans (weitrix_x(魏)na.rm = TRUE)
# # no_s4U_Rep_1 no_s4U_Rep_2 no_s4U_Rep_3 24 h_s4u_rep_1 # # 0.0009467780 0.0008692730 0.0009657405 - 0.0228616995 # # 24 h_s4u_rep_2 24 h_s4u_rep_3 h_chase_rep_1 0 h_chase_rep_2 # # 0.0227623930 0.0224932745 0.0238126807 0.5 0.5 0.5 0.0233169898 # # 0 h_chase_rep_3 h_chase_rep_1 h_chase_rep_2 h_chase_rep_3 # # 0.0232719043 0.0223200231 0.0235324380 0.0231107497 # # 1 h_chase_rep_1 1 h_chase_rep_2 1 h_chase_rep_3 3 h_chase_rep_1 # # 0.0211553204 0.0216421689 0.0212003785 - 0.0138988066 # # 3 h_chase_rep_2 h_chase_rep_3 6 h_chase_rep_1 6 h_chase_rep_2 # # 0.0150091659 0.0149480630 0.0068880708 - 0.0072561156 # # 6 h_chase_rep_3 12 h_chase_rep_1 12 h_chase_rep_2 12 h_chase_rep_3 # # 0.0072943737 0.0022597908 0.0021795891 - 0.0021219205 # # 24 h_chase_rep_1 24 h_chase_rep_2 24 h_chase_rep_3 # # 0.0012122873 0.0010844372 0.0010793906
我们想要每个观测估计的方差。我们可以模型这正如每个观察“T”编码转换作为不改变的0和1,伯努利分布的方差\ \(μμ(1 - \ \)的意思是\μ(\ \)。观察到的比例被平均的值。为\ (n \)这样的价值观,这个平均值的方差
\[\σ^ 2 = \压裂{\μ(1 - \μ)}{n} \]
但是如果我们的估计\μ(\ \)完全为零,方差会变成零,所以重量会成为无限。为了避免无穷量:
这是通过使用mu_min
参数weitrix_calibrate_all
。自然选择剪辑是0.001,明显的背景速度T C转换看到由于测序错误。
另一个可能的问题是生物变异不消失,越来越大\ (n \),所以除以\ (n \)可能是过于乐观的估计。我们将提供\ (n \)(存储在权重)γGLM残差平方的日志链接,利用伯努利方程方差作为补偿。这种漠视用于分配校准砝码。
#计算初始适合提供剩余工资符合< - weitrix_components(魏、设计= ~组)卡尔< - weitrix_calibrate_all(魏、设计=适合trend_formula = ~日志(重量)+偏移量(日志(μ*(1μ))),mu_min = 0.001, mu_max = 0.999)元数据(cal) weitrix all_coef美元
# #(拦截)日志(重量)# # 0.3391974 - -0.9154304
这一趋势验证公式是足够的(尽管不完美)通过检查标定块,如下显示。
之间的转换大量不同时间点,所以我们分别检查。
weitrix_calplot(魏,健康,猫=集团柯伐合金=μ,导游= FALSE) + coord_cartesian (xlim = c(0, - 0.1)) +实验室(title =“校准”)
weitrix_calplot (cal,健康,猫=集团柯伐合金=μ)+ coord_cartesian (xlim = c(0, - 0.1)) +实验室(title =“校准后”)
理想情况下,红线都是水平的。这对非常小的比例是不可能的,因为这就变成了一种零乘以无穷大。
我们也可以检查加权残差与原来的权重(“T”的报道。
weitrix_calplot(魏,健康,猫=集团柯伐合金=日志(weitrix_weights(魏)),导游= FALSE) +实验室(title =“校准”)
weitrix_calplot (cal,健康,猫=集团柯伐合金=日志(weitrix_weights(魏)))+实验室(title =“校准后”)
作为一个快速的方法来检查数据,我们找两个组件的变异。这揭示了快速衰减,衰减缓慢的基因。
comp < - weitrix_components (cal 2 n_restarts = 1)
这些是两个部分的分数:
matrix_long (comp坳美元[1],row_info = colData (cal)) % > % ggplot (aes (x =组,y =值)+ geom_jitter(高度宽度= 0.2,= 0)+ facet_grid (col ~)。
组件C1强调fast-decaying基因:
快< - weitrix_confects (cal comp坳美元,C1)快
表# # # # $调制效应se df fdr_zero row_mean typical_obs_err名称# # 1 1.858 3.459 0.31630 41.44 - 2.989 0.005283 - 0.0047805 e-13 Amd1 # # 2 1.597 4.711 0.64276 41.44 - 1.083 0.030215 - 0.0144462 e-08 Amd2 # # 3 1.264 1.445 0.03835 41.44 - 3.943 0.002195 - 0.0006703 e-31 Ifrd1 # # 4 e-22 1.263 1.619 0.07694 41.44 1.782 0.002626 1.226 1.568 0.07503 41.44 2.253 0.0012190 Sap30 # # 5 e-22 0.002113 - 0.0012067 Kifc1 # # 6 e-29 1.225 1.417 0.04265 41.44 2.624 0.002302 1.203 1.403 0.04483 41.44 2.154 0.0006963 Dbf4 # # 7即使0.001949 - 0.0007571 Ccdc115 # # 8 1.198 1.478 - 0.06360 41.44 - 5.863 0.001844 - 0.0009380 e-24 Nfyc # # 9 1.198 1.327 0.02933 41.44 - 7.248 0.001957 - 0.0004634 e-34 Cdk1 # # 10 1.196 1.536 0.07815 41.44 - 1.827 0.001620 - 0.0009991 e-21 Nr0b1 # 707.0 # mean_coverage # # 1 # # 2 5432.7 36516.7 294.4 # # 3 # # 4 # 5 # 7994.1 # 6 # 31222.0 # 21676.3 # 7 # 8384.4 # 8 # 9 # 54062.4 # 12721.2 # 10 # #……# 11059 # 9947零在罗斯福0.05 # #之前df 17.4对比
热图(weitrix_x (cal)[头(快表名称,美元10),),name =“转换比例”,cluster_columns = FALSE, cluster_rows = FALSE)
组件C2强调缓慢衰减的基因:
< - weitrix_confects缓慢(cal comp坳美元,C2)缓慢
表# # # # $调制效应se df fdr_zero row_mean typical_obs_err名称# # 1 3.194 7.924 0.9348 41.44 - 2.139 0.038940 - 0.0096568 e-09 Morf4l1 # # 2 2.528 5.589 - 0.6318 41.44 - 7.203 0.007956 - 0.0038019平台以及Rplp2 # # 3 2.080 2.770 0.1462 41.44 - 5.222 0.003845 - 0.0009108 e-20 Rpl27 # # 4 e-21 2.027 2.629 0.1314 41.44 7.796 0.003626 2.027 5.673 0.7998 41.44 1.438 0.0008054 Cox5a # # 5 e-07 0.003747 - 0.0034685二# # 6 e-14 2.007 3.093 0.2426 41.44 2.120 0.004813 2.007 2.878 0.1962 41.44 2.559 0.0016940 Snrpf # # 7 e-16 0.005089 - 0.0013159 Psmb2 # # 8 2.007 7.482 1.2418 41.44 - 3.819 0.002823 - 0.0039787 e-06 Pgk1 # # 9 2.006 2.551 0.1246 41.44 - 3.702 0.003584 - 0.0007736 e-21 Banf1 # # 10 1.999 3.173 0.2714 41.44 - 2.910 0.004837 - 0.0017923 e-13 Gm8624 # 887.8 # mean_coverage # # 1 # # 2 61517.9 41892.9 2509.3 # # 3 # # 4 # 5 # 1871.4 # 6 # 12742.6 # 12790.4 # 7 # 959.0 # 8 # 9 # 50657.7 # 10490.3 # 10 # #……# 11059 # 3829零在罗斯福0.05 # #之前df 17.4对比
热图(weitrix_x (cal)[头(缓慢的表名称,美元10),),name =“转换比例”,cluster_columns = FALSE, cluster_rows = FALSE)
进一步检查可能基于显式地建模衰变过程。
数据提取和总计为基因:
图书馆(tidyverse) download.file (" https://www.ncbi.nlm.nih.gov/geo/download/?acc = GSE99970&format =文件”、“GSE99970_RAW.tar”)将(“GSE99970_RAW解压。焦油”,exdir = " GSE99970_RAW”)文件名< -列表。文件(“GSE99970_RAW”, full.names = TRUE) < - str_match样品(文件名,“mESC_ (. *) \ \ . tsv \ \ . gz”) [2] dfs < -地图(文件名、read_tsv评论= " # ")< -做报道。调用(cbind,地图(dfs, CoverageOnTs)) % > % rowsum (dfs[[1]]的名字)美元转换< -。调用(cbind,地图(dfs, ConversionsOnTs)) % > % rowsum (dfs[[1]]的名字)美元colnames(转换)< - colnames(覆盖率)< -样本重新排序< - c(1:3, 25:27 4:24)覆盖(,重新排序)% > % as.data.frame () % > % rownames_to_column(“基因”)% > % write_csv (“GSE99970_T_coverage.csv.gz”)转换(,重新排序)% > % as.data.frame () % > % rownames_to_column(“基因”)% > % write_csv (“GSE99970_T_C_conversions.csv.gz”)