Hi,
I have 8 lists of differential expressed genes between 2-2 h, 4-4h, ..., 16h-16h for two datasets, I mean I have compared time points between datasets. how I can plot the expression of these 8 list across time points???
Hi,
I have 8 lists of differential expressed genes between 2-2 h, 4-4h, ..., 16h-16h for two datasets, I mean I have compared time points between datasets. how I can plot the expression of these 8 list across time points???
You can represent the expression across all samples by mean of heatmap which in turn can be generated using different softwares like
Feel free to utilise this function, the original 'bare bones' of which was written by a colleague (AKA 'Rana') and then modified by me. This comes with absolutely no warranty. Feel free to edit as you please. It requires ggplot2
and reshape
.
x <- data.frame(replicate(10, sample(0:500, 50, replace=TRUE)))
rownames(x) <- paste("gene", c(1:nrow(x)), sep="")
colnames(x)[seq(1,ncol(x), 2)] <- paste("treated.Month", c(1:(ncol(x)/2)), sep="")
colnames(x)[seq(2,ncol(x), 2)] <- paste("untreated.Month", c(1:(ncol(x)/2)), sep="")
x[1:5,]
treated.Month1 untreated.Month1 treated.Month2 untreated.Month2
gene1 413 455 120 249
gene2 316 48 194 419
gene3 190 147 404 95
gene4 345 465 427 394
gene5 17 226 31 38
treated.Month3 untreated.Month3 treated.Month4 untreated.Month4
gene1 9 393 331 462
gene2 300 257 180 294
gene3 395 411 344 229
gene4 159 321 371 42
gene5 213 461 176 480
treated.Month5 untreated.Month5
gene1 452 394
gene2 410 116
gene3 13 425
gene4 254 51
gene5 88 103
bipartite <- function(x, col1, col2, colour, title, premean, postmean, xlab, ylab, yMin, yMax)
{
require(ggplot2)
require(reshape2)
mydf <- x[,c(col1,col2)]
mydf$sampleID <- rownames(x)
#melt dataframe
mydf<- melt(mydf, id.vars="sampleID", variable.name="var", value.name="value")
#plotting in ggplot2
graph <- ggplot(data=mydf, aes(x=var, y=value, group=sampleID)) +
geom_line(size=0.3) +
geom_point(size=2.5, shape=21, fill=colour, colour='black') +
xlab(xlab) + ylab(ylab) +
ylim(yMin, yMax) +
#Set the size of the plotting window
#theme_bw(base_size=24) +
#Modify various aspects of the plot text and legend
theme(
legend.position="none",
legend.background=element_rect(),
plot.title=element_text(angle=0, size=12, face="bold", vjust=1),
axis.text.x=element_text(angle=0, size=12, face="bold", vjust=0.5),
axis.text.y=element_text(angle=0, size=12, vjust=0.5),
axis.title=element_text(size=12),
#Legend
legend.key=element_blank(), #removes the border
legend.key.size=unit(1, "cm"), #Sets overall area/size of the legend
legend.text=element_text(size=12), #Text size
title=element_text(size=12)) + #Title text size
ggtitle(title) +
geom_hline(yintercept=30, colour="red", size=1.25, linetype="solid") +
geom_hline(yintercept=premean, colour="grey2", size=0.75, linetype="dotted") +
geom_hline(yintercept=postmean, colour="grey2", size=0.75, linetype="dotdash")
return(graph)
}
bipartite(x=x, col1="untreated.Month1", col2="treated.Month1",
col="black", title="Untreated Vs. Treated\nMonth 1",
premean=mean(x[,"untreated.Month1"], na.rm=TRUE),
postmean=mean(x[,"treated.Month1"], na.rm=TRUE),
xlab="Group and Timepoint", ylab="Expression",
yMin=0, yMax=max(x, na.rm=TRUE))
The dashed line is the mean in the first time-point; the red line is the mean in the second. You can modify these in the code.
Kevin
Try out complexheatmap package
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
facet them. I guess you can plot either for a single or set of genes. If you could give us more details about experiment design.
Thanks a lot, supposing 8 lists of genes each list contains differentially expressed for 2h, 24, 6h, 8h, 10h, 12h, 14h, 16h time points, I want to plot a trajectory of expression of these genes across time points. The problem is this, the genes inside these lists are not the same although with some overlap because I have done differential expression analysis separately for each time point. So I want to have plot on the change of expression of these genes across time points, something like terajectories
some thing like this: I copied data frame code from Kevin (from below) and plotted data for 10 genes only. Connected the expression data between two points.
output: