开始使用免费开始使用

动手绘制核苷酸频率图

现在,请更细致地查看每个循环中的核苷酸频率。最好的方式是做一张可视化图。通常,前几个循环会有些随机,随后各个循环中的核苷酸频率应当逐步稳定。

本练习使用了完整的 fastq 文件 SRR1971253,并已为您完成了一些预处理:

library(ShortRead)
fqsample <- readFastq(dirPath = "data", 
                      pattern = "SRR1971253.fastq")
# extract reads                      
abc <- alphabetByCycle(sread(fqsample))

# Transpose nucleotides A, C, G, T per column
nucByCycle <- t(abc[1:4,]) 

# Tidy dataset
nucByCycle <- nucByCycle %>% 
  as_tibble() %>% # convert to tibble
  mutate(cycle = 1:50) # add cycle numbers

您的任务是使用 tidyverse 函数绘制"按循环的核苷酸频率"折线图!

本练习是课程的一部分

R 中的 Bioconductor 入门

查看课程

练习说明

  • 使用 glimpse() 查看对象 nucByCycle 的数据概况。
  • 使用 pivot_longer() 将核苷酸字母整理到 alphabet 列,并生成新的 count 列。
  • 绘制折线图:x 轴为 cycle,y 轴为 count,并按 alphabet 着色。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Glimpse nucByCycle
___

# Create a line plot of cycle vs. count
nucByCycle %>% 
  # Gather the nucleotide letters in alphabet and get a new count column
  pivot_longer(-cycle, names_to = ___, values_to = ___) %>% 
  ggplot(aes(x = ___, y =  ___, color = ___)) +
  geom_line(size = 0.5 ) +
  labs(y = "Frequency") +
  theme_bw() +
  theme(panel.grid.major.x = element_blank())
编辑并运行代码