Commit 7ee13203 authored by Guillaume Devailly's avatar Guillaume Devailly
Browse files

plot update

for DPP2022 poster
parent a10dde1c
......@@ -23,9 +23,9 @@ old_metadata <- unique(old_metadata[, c("nanim", "nfcore_id")])
metadata <- merge(x = metadata, y = old_metadata, by.x = "n_nation", by.y = "nanim")
metadata$id <- with(metadata, paste(
line,
condition,
sex,
line,
condition,
sex,
str_trunc(n_nation, 4, "left", ellipsis = ""),
sep = "_")
) # /!\ nfcore_id has the wrong conditions!
......@@ -49,8 +49,8 @@ dge <- DGEList(txi$counts)
# this plot help to decide the threshold
keep <- filterByExpr(dge, min.count = 4, min.total.count = 8 )
summary(keep)
# Mode FALSE TRUE
# logical 18042 13738
# Mode FALSE TRUE
# logical 18042 13738
dge <- dge[keep,]
dge <- calcNormFactors(dge)
......@@ -75,15 +75,15 @@ names(coef_sex)
volcano_rosepigs <- function(coef_table, logFC = 0, adj_pValue = 0.01, title = "") {
coef_table$diffexpressed[coef_table$logFC > logFC & coef_table$adj.P.Val < adj_pValue] <- "UP"
coef_table$diffexpressed[coef_table$logFC < logFC & coef_table$adj.P.Val < adj_pValue] <- "DOWN"
ggplot(data=coef_table, aes(x=logFC, y=-log10(adj.P.Val), col=diffexpressed)) +
geom_point() +
coord_cartesian(xlim = c(-5,5), ylim = c(0,8)) +
annotate("text", x = c(-4,4), y = 8, label = table(coef_table$diffexpressed)) +
labs(title = title) +
theme_bw(base_size = 16) +
theme_bw(base_size = 16) +
theme(legend.position = "none")
}
volcano <- volcano_rosepigs(coef_line, title = "Line") +
......@@ -91,7 +91,7 @@ volcano <- volcano_rosepigs(coef_line, title = "Line") +
volcano_rosepigs(coef_sex, title = "Sex")
# Plots
# Plots
ggsave("plots/volcano.png", volcano, width = 12, height = 4)
# HeatMap -----
......@@ -100,35 +100,31 @@ colnames(expMat) <- metadata$id
# z_score applying
expMat <- t(apply(expMat, MARGIN = 1, function(x) (x - mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)))
heatMap_rosePigs <- function(coef_table, name = "") {
names(metadata)
# Define colors for each levels of qualitative variables
col = list(line = c("G11-" = "#CB4335", "G11+" = "#1F618D"),
condition = c("fed" = "#F39C12", "fasted" = "#1E8449"),
sex = c("F" = "#76448A", "M" = "#F1C40F"),
sex = c("F" = "#76448A", "M" = "#53848B"),
family = c("A" = "#008000", "B" = "#E59866","C" = "#A2D9CE", "D" = "#008080", "E" = "#F7DC6F", "F" = "#000080" ),
deg = c("UP_expressed" = "#4A235A", "DOWN_expressed" = "#CD5C5C"))
# Create the heatmap top_annotation
ha <- HeatmapAnnotation(
line = metadata$line,
condition = metadata$condition,
sex = metadata$sex,
line = metadata$line,
condition = metadata$condition,
sex = metadata$sex,
family = metadata$family,
col = col
)
col_heatmap = colorRamp2(c(-2, 0, 2), c("#0000FF", "white", "#FF0000"))
#hl = rowAnnotation(deg = coef_line$diffexpressed, col = col)
mat <- expMat[rownames(coef_table[coef_table$adj.P.Val < 0.01, ]), ]
Heatmap(mat, col = col_heatmap,
row_title = "Genes(318)",
column_title = "Samples(24)",
Heatmap(mat, col = col_heatmap,
row_title = "Genes(318)",
column_title = "Samples(24)",
name = "Expression Z_score",
row_names_gp = gpar(fontsize = 7),
layer_fun = NULL,
......@@ -136,8 +132,8 @@ heatMap_rosePigs <- function(coef_table, name = "") {
show_column_names = FALSE,
use_raster = TRUE,
top_annotation = ha)
}
#png("plots/heatMap_line.png", width = 1000, height = 1000)
......@@ -153,8 +149,65 @@ svg("plots/heatMap_sex.svg", width = 6, height = 6)
heatMap_sex <- heatMap_rosePigs(coef_sex, name = "Sex")
dev.off()
# merged heatmaps -----------------
col = list(line = c("G11-" = "#CB4335", "G11+" = "#1F618D"),
condition = c("fed" = "#1E8449", "fasted" = "#F39C12"),
sex = c("F" = "#89014D", "M" = "#53848B"),
family = c("A" = "#008000", "B" = "#E59866","C" = "#A2D9CE", "D" = "#008080", "E" = "#F7DC6F", "F" = "#000080" ),
deg = c("UP_expressed" = "#4A235A", "DOWN_expressed" = "#CD5C5C"))
ha <- HeatmapAnnotation(
line = metadata$line,
condition = metadata$condition,
sex = metadata$sex,
family = metadata$family,
col = col
)
col_heatmap = colorRamp2(c(-2.6, 0, 2.6), c("#5555FF", "white", "#FF5555"))
mat <- rbind(
expMat[rownames(coef_condition[coef_condition$adj.P.Val < 0.01, ]), ],
expMat[rownames(coef_line[coef_line$adj.P.Val < 0.01, ]), ],
expMat[rownames(coef_sex[coef_sex$adj.P.Val < 0.01, ]), ]
)
hra <- rowAnnotation(
DGE = c(
ifelse(coef_condition[coef_condition$adj.P.Val < 0.01, ]$logFC > 0, "Up", "Down"),
ifelse(coef_line[coef_line$adj.P.Val < 0.01, ]$logFC > 0, "Up", "Down"),
ifelse(coef_sex[coef_sex$adj.P.Val < 0.01, ]$logFC > 0, "Up", "Down")
),
col = list(DGE = c("Up" = "#86628b", "Down" = "#dc8c8c"))
)
rs <- c(
rep("Condition (962)", nrow(coef_condition[coef_condition$adj.P.Val < 0.01, ])),
rep("Line (318)", nrow(coef_line[coef_line$adj.P.Val < 0.01, ])),
rep("Sex (4)", nrow(coef_sex[coef_sex$adj.P.Val < 0.01, ]))
)
mh <- Heatmap(
mat, col = col_heatmap,
column_title = "Samples (24)",
name = "Expression\n(Z-score)",
top_annotation = ha,
left_annotation = hra,
row_split = rs, cluster_row_slices = FALSE,
column_split = paste(metadata$line, metadata$condition), cluster_columns = FALSE,
row_names_gp = gpar(fontsize = 7),
layer_fun = NULL,
show_row_names = FALSE,
show_column_names = FALSE,
use_raster = TRUE,
)
svg("plots/limma_heatmap_cond_line_sex.svg", width = 6, height = 8)
draw(mh, merge_legends = TRUE)
dev.off()
# boxplot : condition/exression:
# boxplot : condition/exression: --------------
#add line_cond column:
metadata$line_cond <- paste(metadata$line, metadata$condition, sep = "_")
......@@ -164,7 +217,7 @@ plotexpr <- function(gene){
expr <- t(txi$abundance[gene,, drop = FALSE])
dfp <- metadata
dfp$expr <- expr
ggplot(dfp, aes(x = line_cond, y = expr)) +
ylab("Emp") +
xlab("") +
......@@ -175,7 +228,7 @@ plotexpr <- function(gene){
labs(
title = gtf[which(gtf$gene_id == gene & gtf$type == "gene"),, drop = FALSE ]$gene_name
)
}
GHRL <- plotexpr(my_genes[1])
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
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