Closed:problem changing color for annotations
0
0
Entering edit mode
3.2 years ago
Maria • 0

Hi everyone,

I am doing a pheatmap with deseq2 data, and I'm not able to change the colors of the column annotations. I have 12 samples (columns) grouoped in 4 conditions, and I'm doing pair-wise comparisons like this, below. Now, my intention is change de default color of the group annotation to for example orange and skyblu (you can see in the script) but it seems doesn't work, but I don't get any error message. I hope someone can help me out :) Thanks!!

        > > sampleTable    
        sample  NamefileName    condition 
        1      1A 1A_gene_strict.tsv   WT_NS 
        2      2A 2A_gene_strict.tsv   WT_NS 
        3      3A 3A_gene_strict.tsv   WT_NS 
        4      1B 1B_gene_strict.tsv WT_ST
        5      2B 2B_gene_strict.tsv WT_ST
        6      3B 3B_gene_strict.tsv WT_ST
        7     6A 6A_gene_strict.tsv   KO_NS 
        8      7A 7A_gene_strict.tsv   KO_NS
         9     8A 8A_gene_strict.tsv   KO_NS 
        10    6B 6B_gene_strict.tsv KO_ST 
        11    7B 7B_gene_strict.tsv KO_ST
        12    8B 8B_gene_strict.tsv KO_ST

    levels <- unique(sampleTable$condition)
    ll <- length(levels)    

    for (i in 1:(ll-1)) {
            for (j in (i+1):ll) {
                       l1 <- toString(levels[i])
                l2 <- toString(levels[j])
                conditions = c(l1, l2)
                conds = subset(sampleTable, sampleTable$condition %in% conditions)
                samples = conds$sample
                df = data.frame(condition=conds$condition)
                rownames(df) = samples
                my_colour = list(df=c(l1="orange", l2="skyblue"))
                res <- results(dds, contrast=c("condition", l2, l1))
                res$FoldChange <- 2^res$log2FoldChange
                sig <- subset(res, res$padj < cutoff)
                subcounts <- subset(ncounts, rownames(ncounts) %in% rownames(sig))
                subcounts <- subcounts[,rownames(df)]
                lsubcounts <- log2(subcounts+1)
                pheatmap(mat=lsubcounts, color=hmcol, border_color=F, scale="row", cluster_cols=T,
                        cluster_rows=T, fontsize_row=9, annotation_col=df, annotation_colors=my_colour, 
                       show_rownames=F, show_colnames=T, annotation_names_col=F, annotation_names_row=F)
}
}
pheatmap R • 235 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2044 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