Updated intermediate R data visualization materials

This commit is contained in:
Krishna Choudhary 2020-03-24 20:10:44 -07:00
parent 08be3b61c3
commit 0eb7b8b40d
16 changed files with 584 additions and 0 deletions

View file

@ -0,0 +1,41 @@
library(ggplot2)
#Following library will be used to reformat data for plotting.
library(reshape2)
#Load the data for plotting.
load("nucleotide_resolution.RData")
#Open a pdf file for plotting.
pdf("Nucleotide_resolution.pdf")
#Loop through all genes.
for (i in 1:length(dat)) {
#Get data for this gene.
this_dat <- dat[[i]]
#Reformat data for plotting.
this_dat <- melt(this_dat, id.vars = "Position")
#Store the plot in a variable.
p <- ggplot(this_dat, aes(x = Position, y = value)) +
geom_bar(stat = "identity") +
facet_grid(variable ~ .)+
scale_y_continuous(breaks = c(0, 0.5, 1))+
ylab("Signal")+
annotate(geom = "rect",
xmin = to_annotate$Start[i],
xmax = to_annotate$End[i],
ymin = -Inf,
ymax = Inf, fill = "red",
color = NA,
alpha = 0.3) +
ggtitle(names(dat)[i])
#Print plot to file.
print(p)
}
#Close file.
dev.off()