This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Plotting transposons start and end positions

I have multiple transposons start and end positions in a chromosome.

I want to plot it. I want it without using any bioconductor packages.

Can anyone suggest me how to do?

r chromosome

Is there a reason why you don't want to use any bioconductor packages?

I have already plotted in my required scale some other plots without using any packages.

So I felt bit confusing integrating packages with the normal plots.

1 answer

A very rudimentary R script might use plot() and segments():

#!/usr/bin/env Rscript

tpStarts  <- c(5, 10, 20, 25)
tpEnds    <- c(7, 14, 22, 28)
tpYIndex1 <- c(1,  2,  3,  4)
tpYIndex2 <- c(1,  2,  3,  4)
df <- data.frame(tpStarts, tpEnds, tpYIndex1, tpYIndex2)

pdf("graph.pdf", width=5, height=3)
plot(NA, xlim=c(min(df$tpStarts),max(df$tpEnds)), ylim=c(1,4), xlab="Transposon Position", ylab="Transposon Index")
segments(df$tpStarts, df$tpYIndex1, df$tpEnds, df$tpYIndex2, lwd=2)
dev.off()

Thank you Alex . Is there any other way to get an enlarged view of the positions?

Since the positions looks a bit small in size.

You could edit the tpYIndex2 value to be something like c(1.5, 2.5, 3.5, 4.5), etc. also adjusting the ylim maximum to 4.5. You could also edit the lwd parameter upwards to draw thicker lines. Read the R docs on plot() and segments() to see what parameters you can adjust.

Log in to answer this question.