This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create Sequence Chromatogram from Data Frame

Hello!

I have information of a sequence in this data frame:

enter image description here

I would like to make a Seq chromatogram like this:

test

Edited by GenoMax : Since the chromatogram image was not showing up in final display (it showed up in edit preview) I am including a screencap of what OP had included as an embedded image.

chromat

I didn't find any tutorial.

Thanks!

nucleotide graph sequencing chromatogram sequence

1 answer

Can you please elaborate what you want to achieve with this type of plot?

A very primitive approach would be something like shown here:

# simulate some data
seqdata <- as.data.frame(matrix(rbinom(200,1,0.25),ncol=4))
colnames(seqdata) <- c("A","C","G","T")
seqdata[,"pos"] <- as.numeric(rownames(seqdata))

# plot
library(tidyverse)
seqdata  %>% gather("base", "count", -pos) %>% filter(count > 0) %>% ggplot(aes(x=pos,color=base)) + geom_density(adjust=1/dim(seqdata)[1]) + facet_grid(base~.)

However, this just represents an ideal chromatogram. A real one measured one by capillary electrophoresis would exhibit e.g. noise at the start, broad merged peaks at base repeats, a decreasing signal towards the end etc.

Log in to answer this question.