jokergoo / EnrichedHeatmap

make enriched heatmap which visualizes the enrichment of genomic signals to specific target regions.
http://jokergoo.github.io/EnrichedHeatmap/
Other
187 stars 25 forks source link

Convert from continuous matrix to discrete matrix #26

Closed jokergoo closed 6 years ago

jokergoo commented 6 years ago

Assume a normalized matrix has both positive value and negative value, we only want to see the enrichment of windows/regions show significant positive values and negative values and we are only interested in the direction of the values while not the value itself:

rule = list(
    "positive" = c(0.5, Inf),
    "negative" = c(-Inf, -0.5)
)

mat2 = discretize(mat, rule)
EnrichedHeatmap(mat, col = colorRamp2(c(-1, 0, 1), c("green", "white", "red")))
EnrichedHeatmap(mat2, col = c("positive" = "red", "negative" = "green"))

Or something like:

rule = list(
    "very_high" = c(100, Inf),
    "high" = c(50, 100),
    "intermediate" = c(25, 50),
    "low" = c(0, 25)
)
jokergoo commented 6 years ago

library(EnrichedHeatmap)
load(system.file("extdata", "chr21_test_data.RData", package = "EnrichedHeatmap"))
tss = promoters(genes, upstream = 0, downstream = 1)
mat1 = normalizeToMatrix(H3K4me3, tss, value_column = "coverage",
    extend = 5000, mean_mode = "w0", w = 50)

ht1 = EnrichedHeatmap(mat1, col = colorRamp2(quantile(mat1, c(0, 0.99)), c("white", "red")), 
    column_title = "continuous")

rule = list("high" = c(40, Inf), 
            "intermediate" = c(20, 40), 
            "low" = c(1e-6, 20))
mat2 = discretize(mat1, rule)
ht2 = EnrichedHeatmap(mat2, col = c("high" = "red", "intermediate" = "blue", "low" = "green"),
    column_title = "discrete")

ht1 + ht2

image