Commit 4560b203 authored by Teresa Tavella's avatar Teresa Tavella
Browse files

add data and script

parent e777651b
--- ---
title: "geing GSEA reactome plot divided by category" pdf_document: default
author: "" author: ''
output: output:
html_document: html_document: null
df_print: paged df_print: paged
pdf_document: default
word_document: default word_document: default
pdf_document: default title: "geing GSEA reactome plot divided by category"
--- ---
...@@ -243,7 +244,7 @@ doHeatmap3 <- function(df, sinfo, num_row_clu = 2, high_genes = NULL, top_annot ...@@ -243,7 +244,7 @@ doHeatmap3 <- function(df, sinfo, num_row_clu = 2, high_genes = NULL, top_annot
width = 10, height = 10, width = 10, height = 10,
heatmap_legend_param = list( heatmap_legend_param = list(
title = "Z-score", title = "Z-score",
at = c(round(min(hm_matrix)),0,round(max(hm_matrix))), #at = c(round(min(hm_matrix)),0,round(max(hm_matrix))),
legend_direction = "horizontal", legend_direction = "horizontal",
legend_width = unit(4, "cm")), legend_width = unit(4, "cm")),
) )
...@@ -286,9 +287,9 @@ mat_gg <- as.data.frame(dimicco$deseq$rlog)[unique(gg), ] ...@@ -286,9 +287,9 @@ mat_gg <- as.data.frame(dimicco$deseq$rlog)[unique(gg), ]
annocat_signif <- annotcat[rownames(mat_gg),] annocat_signif <- annotcat[rownames(mat_gg),]
mat_gg_scaled <- t(scale(t(mat_gg))) mat_gg_scaled <- t(scale(t(mat_gg)))
dimicco_hm <- doHeatmap2(df = t(mat_gg_scaled), sinfo = sinfo, high_genes =unique(gg)) #dimicco_hm <- doHeatmap2(df = t(mat_gg_scaled), sinfo = sinfo, high_genes =unique(gg))
rorder <- row_order(dimicco_hm) #rorder <- row_order(dimicco_hm)
mat_gg_scaled_names <- mat_gg_scaled[rorder,] #mat_gg_scaled_names <- mat_gg_scaled[rorder,]
annocat_signif <- annocat_signif[,dt$Description] annocat_signif <- annocat_signif[,dt$Description]
annocat_signif <- annocat_signif[rownames(mat_gg_scaled ),] # order automatically annocat_signif <- annocat_signif[rownames(mat_gg_scaled ),] # order automatically
...@@ -304,13 +305,13 @@ for (i in dt$Description) { ...@@ -304,13 +305,13 @@ for (i in dt$Description) {
cn <- dt[dt$Description == i, 'Category'] cn <- dt[dt$Description == i, 'Category']
colors[i] <- my_cols[[cn]] colors[i] <- my_cols[[cn]]
} }
ht3 = Heatmap(as.matrix(annocat_signif), name = " ",show_column_names = TRUE, # ht3 = Heatmap(as.matrix(annocat_signif), name = " ",show_column_names = TRUE,
show_row_names =FALSE, # show_row_names =FALSE,
border = TRUE,row_names_gp = gpar(fontsize = 4), # border = TRUE,row_names_gp = gpar(fontsize = 4),
column_names_gp = gpar(fontsize = 6, rot = 90), # column_names_gp = gpar(fontsize = 6, rot = 90),
rect_gp = gpar(col = "black", lwd = 0.5), # rect_gp = gpar(col = "black", lwd = 0.5),
col = colors ,na_col = "white", # col = colors ,na_col = "white",
heatmap_legend_param = list(labels = dt$Category ))#c(rep('', dim(annocat_signif)[2]))) ) # heatmap_legend_param = list(labels = dt$Category ))#c(rep('', dim(annocat_signif)[2]))) )
## hm of gene in core enrichment and also signif all categories ## hm of gene in core enrichment and also signif all categories
# svg(filename=paste(plot.dir, paste0("HM_full_categories", "_ON_Old_vs_Young.svg"), sep = "/"), # svg(filename=paste(plot.dir, paste0("HM_full_categories", "_ON_Old_vs_Young.svg"), sep = "/"),
...@@ -342,17 +343,18 @@ annocat_signif <- annotcat[rownames(mat_gg),] ...@@ -342,17 +343,18 @@ annocat_signif <- annotcat[rownames(mat_gg),]
#annocat_signif <- annocat_signif[,dt$Category] #annocat_signif <- annocat_signif[,dt$Category]
#annocat_signif <- annocat_signif[rownames(mat_gg_scaled ),] # order automatically #annocat_signif <- annocat_signif[rownames(mat_gg_scaled ),] # order automatically
table(rownames(annocat_signif ) == rownames(mat_gg_scaled)) table(rownames(annocat_signif ) == rownames(mat_gg_scaled))
my_cols <- c(hue_pal()(length(levels(dt$Category)))) my_cols <- c(hue_pal()(length(levels(dt$Category))))
names(my_cols) <- levels(dt$Category) names(my_cols) <- levels(dt$Category)
ht3 = Heatmap(as.matrix(annocat_signif), name = " ",show_column_names = TRUE, # ht3 = Heatmap(as.matrix(annocat_signif), name = " ",show_column_names = TRUE,
show_row_names =FALSE, # show_row_names =FALSE,
border = TRUE,row_names_gp = gpar(fontsize = 12), # border = TRUE,row_names_gp = gpar(fontsize = 12),
column_names_gp = gpar(fontsize = 12, rot = 90), # column_names_gp = gpar(fontsize = 12, rot = 90),
rect_gp = gpar(col = "black", lwd = 0.5), # rect_gp = gpar(col = "black", lwd = 0.5),
col = my_cols ,na_col = "white", # col = my_cols ,na_col = "white",
heatmap_legend_param = list(labels = levels(dt$Category) ))#c(rep('', dim(annocat_signif)[2]))) ) # heatmap_legend_param = list(labels = levels(dt$Category) ))#c(rep('', dim(annocat_signif)[2]))) )
# svg(filename=paste(plot.dir, paste0("HM_reduced_categories", "_ON_Old_vs_Young.svg"), sep = "/"), # svg(filename=paste(plot.dir, paste0("HM_reduced_categories", "_ON_Old_vs_Young.svg"), sep = "/"),
# width=12, # width=12,
...@@ -394,52 +396,52 @@ dev.off() ...@@ -394,52 +396,52 @@ dev.off()
##### HM of genes in the core enrichment and also signif single HM ##### HM of genes in the core enrichment and also signif single HM
```{r echo=FALSE,echo=FALSE, warning=FALSE,message=FALSE} ```{r echo=FALSE,echo=FALSE, warning=FALSE,message=FALSE}
####################################################### #######################################################
#
for (y in unique(dt$Category)) { ## for each macro category # for (y in unique(dt$Category)) { ## for each macro category
gg <- c() # gg <- c()
for (n in names(real_sig)) { # for (n in names(real_sig)) {
if (n %in% dt[dt$Category == y,'Description']){ # if (n %in% dt[dt$Category == y,'Description']){
print(n) # print(n)
#gg <- rownames(real_sig[[n]]) # #gg <- rownames(real_sig[[n]])
gg <- append(gg,rownames(real_sig[[n]])) # gg <- append(gg,rownames(real_sig[[n]]))
} # }
} # }
gx <- unique(gg) # gx <- unique(gg)
mat_gg <- as.data.frame(dimicco$deseq$rlog)[gx, ] # mat_gg <- as.data.frame(dimicco$deseq$rlog)[gx, ]
mat_gg_scaled <- t(scale(t(mat_gg))) # mat_gg_scaled <- t(scale(t(mat_gg)))
dimicco_hm <- doHeatmap2(df = mat_gg_scaled, sinfo = sinfo) # dimicco_hm <- doHeatmap2(df = mat_gg_scaled, sinfo = sinfo)
#
str(sinfo) # str(sinfo)
n <- gsub(' ','_',gsub('/','_',n)) # n <- gsub(' ','_',gsub('/','_',n))
# svg(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.svg"), sep = "/"), # # svg(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.svg"), sep = "/"),
# width=6, # # width=6,
# height=6, # # height=6,
# pointsize=12) # # pointsize=12)
# draw(dimicco_hm) # # draw(dimicco_hm)
# dev.off() # # dev.off()
# # #
if (length(gx) > 39) { # if (length(gx) > 39) {
png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"), # png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"),
units = "in", width = 8, height = 25, res = 300) # units = "in", width = 8, height = 25, res = 300)
draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y) # draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y)
dev.off() # dev.off()
} else if (length(gx) > 22) { # } else if (length(gx) > 22) {
png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"), # png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"),
units = "in", width = 5, height = 8, res = 300) # units = "in", width = 5, height = 8, res = 300)
draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y) # draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y)
dev.off() # dev.off()
} else if (length(gx) > 10) { # } else if (length(gx) > 10) {
png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"), # png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"),
units = "in", width = 5, height = 6, res = 300) # units = "in", width = 5, height = 6, res = 300)
draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y) # draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y)
dev.off() # dev.off()
} else { # } else {
png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"), # png(filename=paste(plot.dir, paste0("HM_", y, "_ON_Old_vs_Young.png"), sep = "/"),
units = "in", width = 4, height = 4, res = 300) # units = "in", width = 4, height = 4, res = 300)
draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y) # draw(dimicco_hm, merge_legend = TRUE,heatmap_legend_side = 'top',column_title =y)
dev.off() # dev.off()
} # }
} # }
``` ```
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment