Drawing a heatmap with only limited genes
1
0
Entering edit mode
@6d47e22d
Last seen 16 months ago
Pakistan

![heat map drawn; overwriting of labels and overcrowded]

Hi! The heatmap i have is overly crowded. How can I just show top 25 differentially expressed genes (both over and underexpressed genes) in my heat map?

Further, I am also getting this message:

"It seems you are using RStudio IDE. There are many legends and they are wrapped into multiple rows/columns. The arrangement relies on the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the legend positions might be wrong. You can directly use e.g. pdf() to save the plot into a file."

Tried to draw the heat map without log2FC and average expression columns but its still quite packed. Increased the resolution but fonts become very tiny and there s still overwriting of labels.]

```countData <- read.csv ("MTB2_countframe.csv", sep= ",", row.names="Geneid")

View(colData) View(countData) colData <- read.csv ("MTB2_coldata.csv") dds <- DESeqDataSetFromMatrix( countData = countData, colData = colData, design = ~treatment) dds <- DESeq(dds) res <- results(dds) res
dds$treatment <- relevel(dds$treatment, ref = "untreated") dds <- DESeq(dds) res <- results(dds) res resSig <- res[ which(res$padj < 0.05), ] head(resSig) df <-as.data.frame(resSig) df df.top <- df[(df$baseMean > 50) & abs(df$log2FoldChange) > 0.5, ] df.top <-df.top[order(df.top$log2FoldChange, decreasing = TRUE), ] rlog_out <- rlog( dds, blind = FALSE) colData1 <-read.csv ("MTB2_coldata.csv", row.names = 1) mat <-assay(rlog_out)[row.names(df.top), rownames(colData1)] colnames(mat) <-rownames(colData1) base_mean <-rowMeans( mat) mat.scaled <- t(apply(mat, 1, scale )) colnames(mat.scaled) <- colnames(mat) pheatmap( mat.scaled) num_keep <-25 l2_val <-as.matrix( df.top[ rows_keep,] $log2FoldChange) colnames(l2_val) <- "logFC" mean <- as.matrix(df.top[rows_keep,]$baseMean) colnames(mean) <-"AveExpr" library( "ComplexHeatmap") library("RColorBrewer") l>ibrary( "circlize")

col_logFC <- colorRamp2(c(min(l2_val), 0, max(l2_val)), c ("blue", "white", "red")) col_AveExpr <-colorRamp2(c(quantile(mean)1, quantile(mean)[4]), c("white", "red")) h1 <-Heatmap(mat.scaled[rows_keep,], cluster_rows = F, column_labels = colnames(mat.scaled), name= "Z-score", cluster_columns = T)

h2 <-Heatmap(l2_val, row_labels = df.top$symbol[rows_keep], cluster_rows = F, name="logFC", col = col_logFC, layer_fun = function(j, i, x, y, w, h, col) grid.text(round(l2_val[i, j],2), x, y))

h3 <- Heatmap(mean, row_labels = df.top$symbol[rows_keep], cluster_rows = F, name = "AveExpr", col=col_AveExpr, layer_fun = function( j, i, x, y, w, h, col) grid.text(round(mean[i, j],2), x, y))

h<- h1+h2+h3"'

include your problematic code here with any corresponding output

please also include the results of running the following in an R session

sessionInfo( )

```R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22000)

Matrix products: default

attached base packages: 1 grid stats4 stats graphics grDevices utils datasets [8] methods base

other attached packages: 1 rafalib_1.0.0 RColorBrewer_1.1-3
[3] dbplyr_2.3.2 ComplexHeatmap_2.16.0
[5] DEGreport_1.36.0 circlize_0.4.15
[7] apeglm_1.22.1 DESeq2_1.40.1
[9] SummarizedExperiment_1.30.2 Biobase_2.60.0
[11] MatrixGenerics_1.12.2 matrixStats_1.0.0
[13] GenomicRanges_1.52.0 GenomeInfoDb_1.36.0
[15] IRanges_2.34.0 S4Vectors_0.38.1
[17] BiocGenerics_0.46.0 conflicted_1.2.0.9000
[19] lubridate_1.9.2 forcats_1.0.0
[21] stringr_1.5.0 dplyr_1.1.2
[23] purrr_1.0.1 readr_2.1.4
[25] tidyr_1.3.0 tibble_3.2.1
[27] ggplot2_3.4.2 tidyverse_2.0.0

loaded via a namespace (and not attached): 1 DBI_1.1.3 mnormt_2.1.1
[3] bitops_1.0-7 rlang_1.1.1
[5] magrittr_2.0.3 clue_0.3-64
[7] GetoptLong_1.0.5 compiler_4.3.0
[9] png_0.1-8 vctrs_0.6.3
[11] pkgconfig_2.0.3 shape_1.4.6
[13] crayon_1.5.2 fastmap_1.1.1
[15] backports_1.4.1 XVector_0.40.0
[17] utf8_1.2.3 tzdb_0.4.0
[19] xfun_0.39 zlibbioc_1.46.0
[21] cachem_1.0.8 reshape_0.8.9
[23] DelayedArray_0.26.3 BiocParallel_1.34.2
[25] psych_2.3.3 broom_1.0.5
[27] parallel_4.3.0 cluster_2.1.4
[29] R6_2.5.1 stringi_1.7.12
[31] limma_3.56.2 numDeriv_2016.8-1.1
[33] Rcpp_1.0.10 iterators_1.0.14
[35] knitr_1.43 Matrix_1.5-4
[37] timechange_0.2.0 tidyselect_1.2.0
[39] rstudioapi_0.14 doParallel_1.0.17
[41] codetools_0.2-19 lattice_0.21-8
[43] plyr_1.8.8 withr_2.5.0
[45] coda_0.19-4 ConsensusClusterPlus_1.64.0 [47] pillar_1.9.0 foreach_1.5.2
[49] generics_0.1.3 RCurl_1.98-1.12
[51] emdbook_1.3.12 hms_1.1.3
[53] munsell_0.5.0 scales_1.2.1
[55] glue_1.6.2 tools_4.3.0
[57] locfit_1.5-9.8 mvtnorm_1.2-2
[59] cowplot_1.1.1 bbmle_1.0.25
[61] bdsmatrix_1.3-6 edgeR_3.42.4
[63] colorspace_2.1-0 nlme_3.1-162
[65] GenomeInfoDbData_1.2.10 cli_3.6.1
[67] fansi_1.0.4 S4Arrays_1.0.4
[69] ggdendro_0.1.23 gtable_0.3.3
[71] logging_0.10-108 digest_0.6.31
[73] ggrepel_0.9.3 rjson_0.2.21
[75] memoise_2.0.1 lifecycle_1.0.3
[77] GlobalOptions_0.1.2 MASS_7.3-58.4 "'

heatmaps • 926 views
ADD COMMENT
0
Entering edit mode

How I can change?

ADD REPLY
0
Entering edit mode
sayite3688 • 0
@cfd2ffdc
Last seen 16 months ago
Belize

How I can change? "h2 <-Heatmap(l2_val, row_labels = df.top$symbol[rows_keep], cluster_rows = F, name="logFC", col = col_logFC, layer_fun = function(j, i, x, y, w, h, col) grid.text(round(l2_val[i, j],2), x, y))" Follow the instructions in this article how to screenshot on windows . Using Press PrtScn, Take A Screenshot With Snipping Tool, Game Bar.

ADD COMMENT

Login before adding your answer.

Traffic: 572 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6