2017-10-16 3 views
0

Ich versuche meine Gene Ontology Daten mit GOplot Paket, speziell GOHeat() Funktion, zu plotten. Leider gibt es ein Problem mit der Anzeige von Gen-Namen - x-Achsen-Label auf der Handlung. Hier ist die Visualisierung des Problems:GOHeat - x Achsenbeschriftungen (Gennamen) werden nicht in der Zeichnung angezeigt

Grundstück von Vignette, die ist, wie es aussehen sollte: enter image description here

und hier ist, wie es aussieht, wenn ich es zeichnen:

enter image description here

Ich entschied sich für eine nehmen näher auf GOHeat() -Funktion und es ist preety einfach, die ganze Funktion ist here aber ich habe versucht, ggplot() zu ändern:

g <- ggplot() + 
    geom_tile(data = df_o, aes(x = x, y = y, fill = z))+ 
    scale_x_discrete(breaks = 1:length(unique(df_o$x)), labels = unique(df_o$lab)) + 
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5), axis.title.x=element_blank(), axis.title.y=element_blank(), 
      axis.text.y = element_text(size = 14), panel.background=element_blank(), panel.grid.major=element_blank(), 
      panel.grid.minor=element_blank()) 

Ich denke, dass die Marigins in axis.text.x = element_text(...) aber meine Bemühungen die Handlung überhaupt nicht geändert haben, oder sogar Ome Fehler aufgetreten sind.

Um die Dinge einfacher zeige ich, wie Daten wie folgt aussieht:

> head(unique(df_o$x)) 
[1] 1 2 3 4 5 6 
> head(unique(df_o$lab)) 
[1] TGFBR3 NRP2 GNA13 SLC22A5 APOE LEPR 
37 Levels: ACVRL1 AMOT APOE ATP6V0A1 CAV1 CDH2 CDH5 CERKL CXCR4 ECSCR  EFNB2 FGF2 ... VANGL2 

ich für jeden Hinweis sehr dankbar sein werde, wie man ‚einschalten‘ x-Achse Etiketten. Hier

Antwort

1

ist eine feste Funktion:

GOHeat_fix <- function (data, nlfc, fill.col) 
{ 
    x <- y <- z <- NULL 
    if (missing(nlfc)) 
    nlfc <- 0 
    else nlfc <- nlfc 
    if (missing(fill.col)) 
    fill.col <- c("firebrick", "white", "dodgerblue") 
    else fill.col <- fill.col 
    distance <- dist(data) 
    cluster <- hclust(distance) 
    M <- dim(data)[2] 
    nterm <- M - nlfc 
    if (nlfc == 0) { 
    s <- rowSums(data[, 1:nterm]) 
    tmp <- NULL 
    for (r in 1:nrow(data)) { 
     tmp <- c(tmp, as.numeric(gsub(1, s[r], data[r, 1:nterm]))) 
    } 
    } 
    else { 
    tmp <- NULL 
    for (r in 1:nrow(data)) { 
     tmp <- c(tmp, as.numeric(gsub(1, data[r, (nterm + 
                1)], data[r, 1:nterm]))) 
    } 
    } 
    df <- data.frame(x = factor(rep(cluster$order, each = nterm)), y = rep(colnames(data[, 
                       1:nterm]), length(rownames(data))), z = tmp, lab = rep(rownames(data), 
                                     each = nterm)) 
    df_o <- df[order(df$x), ] 
    g <- ggplot() + 
    geom_tile(data = df_o, aes(x = x, y = y, fill = z)) + 
    scale_x_discrete(breaks = 1:length(unique(df_o$x)), labels = unique(df_o$lab)) + 
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1), 
      axis.title.x = element_blank(), 
      axis.title.y = element_blank(), 
      axis.text.y = element_text(size = 14), 
      panel.background = element_blank(), 
      panel.grid.major = element_blank(), 
      panel.grid.minor = element_blank()) + 
    coord_fixed() 
    if (nlfc == 0) { 
    g + scale_fill_gradient2("Count", space = "Lab", low = fill.col[2], 
          mid = fill.col[3], high = fill.col[1]) 
    } 
    else { 
    g + scale_fill_gradient2("logFC", space = "Lab", low = fill.col[3], 
          mid = fill.col[2], high = fill.col[1]) 
    } 
} 

Beispiel:

library(GOplot) 
data(EC) 
circ <- circle_dat(EC$david, EC$genelist) 
chord <- chord_dat(data = circ, genes = EC$genes, process = EC$process) 
GOHeat_fix(chord[,-8], nlfc = 0) 

enter image description here

ich das Problem mit Etiketten festgelegt und hinzugefügt coord_fixed() da das ist, wie Heatmaps sind in der Regel gemacht.

+0

Wow, einfach unglaublich, vielen Dank! – Adamm

Verwandte Themen