Visualize nucleotides for every position in R

3


R

• 2.1k views

updated 2 hours ago by

▴

70

written 3.5 years ago by

▴

40

You need to change your code. It is not alphabet frequency. It is consensus matrix. Example code and image below:

library(Biostrings)
fastq <- readDNAStringSet("sample.fastq","fastq")
## At each position, base frequency
afmc=consensusMatrix(fastq, baseOnly=T,as.prob = T)
tafmc=t(afmc)
matplot(tafmc[,-5], type="l", lwd=2, xlab="Read Length", ylab= "Base frequency at each position")
legend(legend = colnames(tafmc)[-5],"topright",col=1:4, lty=1:4, lwd=2)

test

5th column is others (other than A,T, G and C).

This is per-cycle base content. R is not good at, and is not designed for such task.

Why complicate life? Just use fastp to do the easiest and fastest way for such tasks, including QC and filtering. It will output the figures like what you want.

3.5 years ago by


chen

&starf;

2.1k


Login
before adding your answer.

Traffic: 1609 users visited in the last hour



Source link