#allChrom - chromosomes from whole dataset.
#chromWithDisease - chromosomes which are u insterested in
#graphName - Barplot name
visualizeChromosome <- function(allChrom,chromWithDisease,graphName) {
library(data.table)
library(ggplot2)
theme_set(theme_classic())
pr <- c()
for(i in 1:24) {
pr[i] <- (sum(chromWithDisease == i)/sum(allChrom == i))*100
}
df <- data.frame("chrom" = c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", "chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", "chrY")
, "percentage" = pr )
df$chrom <- factor(df$chrom,levels = c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", "chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", "chrY"))
ggplot(df,aes(x=chrom, y=percentage,fill=rownames(df), label= rownames(df))) + geom_bar(stat="identity", width = 0.5) +
labs(title=graphName,
subtitle="Chromosome positions percent which are associated with disease",
caption="Source: EWAS Atlas dataset") +
theme(axis.text.x = element_text(angle=65, vjust=0.6)) + scale_y_continuous(name="Percentage") + guides(fill=FALSE)
}
visualizeCpGIslands <- function(allCpG,CpGWithDisease,graphName) {
library(data.table)
library(ggplot2)
theme_set(theme_classic())
CpG <- c("Island", "N_Shore", "S_Shore", "S_Shelf")
pr <- c()
for(i in 1:4) {
pr[i] <- (sum(CpGWithDisease == CpG[i])/sum(allCpG == CpG[i]))*100
}
df <- data.frame("CpG" = c("Island", "N_Shore", "S_Shore", "S_Shelf")
, "percentage" = pr )
ggplot(df,aes(x=CpG, y=percentage,fill=rownames(df), label= rownames(df))) + geom_bar(stat="identity", width = 0.5) +
labs(title=graphName,
subtitle="CpG Islands percent which are associated with disease",
caption="Source: EWAS Atlas dataset") +
theme(axis.text.x = element_text(angle=65, vjust=0.6)) + scale_y_continuous(name="Percentage") + guides(fill=FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.