ToB企服应用市场:ToB评测及商务社交产业平台

标题: 玉米中的元基因调控网络突出了功能上干系的调控相互作用\mo.20a3.R [打印本页]

作者: 海哥    时间: 2024-12-30 16:09
标题: 玉米中的元基因调控网络突出了功能上干系的调控相互作用\mo.20a3.R
这个脚本的重要作用是处置惩罚和分析RNA-seq数据,进行样本的聚类分析、降维可视化,并且将结果生存下来。详细来说,它包括以下几个关键步骤:
1. 读取RNA-seq数据


2. 样本信息的加载与归并


3. 聚类分析(层次聚类)


4. 降维分析与可视化


5. 样本数据的清算与生存


6. 文件生存



总结:

该脚本的焦点目标是处置惩罚RNA-seq数据并进行多种数据分析和可视化,包括:

这些步骤为后续的生物学分析(如基因表达模式的分析、差别分析等)奠定了基础。
第一部门:设置工作目次并加载数据

  1. genome = 'Osativa'
  2. t_cfg = read_projects(genome)
  3. t_cfg %>% print(n=50)
  4. yid = 'mo20a3'
  5. dirw = glue("{dird}/11_qc/{genome}/{yid}")
  6. if(!dir.exists(dirw)) dir.create(dirw)
复制代码
解析
这一部门的重要功能是初始化工作情况并加载数据配置文件,之后为后续的分析步骤设置目次结构。
第二部门:读取原始数据并归并样本信息

  1. #{{{ raw: read in
  2. res = rnaseq_cpm_raw(yid, genome)
  3. th = res$th; tm = res$tm; tl = res$tl; th_m = res$th_m; tm_m = res$tm_m
  4. th2 = read_xlsx(glue("~/projects/cold/data/samples.xlsx")) %>%
  5.     replace_na(list(Name='?', ColdTolerant='?'))
  6. th = res$th %>% left_join(th2, by="Genotype") %>%
  7.     mutate(lab = str_c(Genotype, Name, Treatment, ColdTolerant, sep='_'))
  8. tm = res$tm %>% filter(SampleID %in% th$SampleID) %>%
  9.     mutate(value=asinh(CPM))
  10. #}}}
复制代码
解析
这一部门的关键任务是:

第三部门:聚类分析与可视化(hclust & tSNE)

  1. #{{{ raw: hclust & tSNE
  2. p1 = plot_hclust(tm, th, pct.exp = .7, cor.opt = 'pearson', var.col = 'Treatment', expand.x = .4)
  3. ggsave(file.path(dirw, '11.hclust.p.pdf'), p1, width = 6, height = 8)
  4. p1 = plot_hclust(tm, th, pct.exp = .7, cor.opt = 'spearman', var.col = 'Treatment', expand.x = .4)
  5. ggsave(file.path(dirw, '11.hclust.s.pdf'), p1, width = 6, height = 8)
  6. p2 = plot_pca(tm, th, pct.exp = .7, pca.center = T, pca.scale = F,
  7.     var.shape = 'ColdTolerant', var.col = 'Treatment', var.lab = 'Name',
  8.     legend.pos = 'bottom.left', legend.dir = 'v', pal.col = 'aaas')
  9. ggsave(file.path(dirw, '11.pca.pdf'), p2, width = 6, height = 6)
  10. p3 = plot_tsne(tm, th, pct.exp = .8, perp = 3, iter = 1200, seed = 2,
  11.     var.shape = 'ColdTolerant', var.col = 'Treatment', var.lab = 'Name',
  12.     legend.pos = 'top.right', legend.dir = 'v', pal.col = 'aaas')
  13. ggsave(file.path(dirw, '11.tsne.pdf'), p3, width = 6, height = 6)
  14. #}}}
复制代码
解析
总结:

这一部门的代码实现了:

这些可视化有助于研究者了解数据的整体结构、样本的聚类情况以及不同处置惩罚组或冷耐心状态下的差别。
好的,接下来是第四部门:数据处置惩罚与生存(过滤样本信息与生存元数据)
第四部门:数据处置惩罚与生存(过滤样本信息与生存元数据)

  1. #{{{ raw: filter/fix samples
  2. th2 = res$th
  3. th2 = complete_sample_list(th2)
  4. fh = file.path(dirw, '01.meta.tsv')
  5. write_tsv(th2, fh, na='')
  6. #}}}
复制代码
解析
总结:

这一部门的重要任务是:

好的,最后是第五部门:读取RNA-seq数据并重新进行聚类与可视化
第五部门:读取RNA-seq数据并重新进行聚类与可视化

  1. #{{{ read in
  2. res = rnaseq_cpm(yid)
  3. th = res$th; tm = res$tm; tl = res$tl; th_m = res$th_m; tm_m = res$tm_m
  4. th2 = read_xlsx(glue("~/projects/cold/data/samples.xlsx")) %>%
  5.     replace_na(list(Name='?', ColdTolerant='?'))
  6. th = res$th %>% left_join(th2, by="Genotype") %>%
  7.     mutate(lab = str_c(Genotype, Name, Treatment, ColdTolerant, sep='_'))
  8. tm = res$tm %>% filter(SampleID %in% th$SampleID) %>%
  9.     mutate(value=asinh(CPM))
  10. #}}}
  11. #{{{ hclust & tSNE
  12. p1 = plot_hclust(tm, th, pct.exp = .7, cor.opt = 'pearson', var.col = 'Treatment', expand.x = .4)
  13. ggsave(file.path(dirw, '21.hclust.p.pdf'), p1, width = 6, height = 8)
  14. p1 = plot_hclust(tm, th, pct.exp = .7, cor.opt = 'spearman', var.col = 'Treatment', expand.x = .4)
  15. ggsave(file.path(dirw, '21.hclust.s.pdf'), p1, width = 6, height = 8)
  16. p2 = plot_pca(tm, th, pct.exp = .7, pca.center = T, pca.scale = F,
  17.     var.shape = 'ColdTolerant', var.col = 'Treatment', var.lab = 'Name',
  18.     legend.pos = 'bottom.left', legend.dir = 'v', pal.col = 'aaas')
  19. ggsave(file.path(dirw, '21.pca.pdf'), p2, width = 6, height = 6)
  20. p3 = plot_tsne(tm, th, pct.exp = .8, perp = 3, iter = 1200, seed = 2,
  21.     var.shape = 'ColdTolerant', var.col = 'Treatment', var.lab = 'Name',
  22.     legend.pos = 'top.right', legend.dir = 'v', pal.col = 'aaas')
  23. ggsave(file.path(dirw, '21.tsne.pdf'), p3, width = 6, height = 6)
  24. #}}}
复制代码
解析
总结:

这一部门的代码做了以下几件事情:

这与前面处置惩罚的流程雷同,只是数据加载和分析的操作略有不同。重要是为了确保数据的同等性和正确性,随后生成新的聚类与降维结果。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4