Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • sindrle
    Senior Member
    • Aug 2013
    • 266

    Troubleshot Heatmap

    Hi!
    Im learning to make heat maps.

    I have used this data as a test:
    http://llmpp.nih.gov/DLBCL/ called "Web Figure 1 Data file"

    This is the code I used:

    data <- read.table(file = "~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", header = FALSE, skip = 1, sep = "\t")

    dim(data)

    test <- count.fields("~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", sep="\t")
    which(test != 295)

    header = scan("~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", "", n = 295)
    colnames(data) = header
    fixdata <- data[-7401,]

    x <- data.matrix(fixdata[,-2], rownames.force = NA)

    rownames(x) <- fixdata[,1]
    x[is.na(x)] = 0

    colclust <- hclust(as.dist(1-cor(x, method="pearson")), method="average")

    rowclust <- hclust(as.dist(1-cor(t(x), method="pearson")), method="complete")

    z <- x[rev(rowclust$labels[rowclust$order]), colclust$labels[colclust$order]]

    plotHeatmap(z, fast = TRUE)

    Plotting z:
    Rplot2.pdf

    Heatmap:
    Click image for larger version

Name:	Screen Shot 2014-02-16 at 08.50.13.png
Views:	1
Size:	19.5 KB
ID:	308389


    What has happened here?

    Thanks!
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    There are NAs in the data, which "cor()" doesn't handle how you likely want by default. See the "use=" option.

    Comment

    • sindrle
      Senior Member
      • Aug 2013
      • 266

      #3
      Hi again!
      I have updated the script, handling a lot of rows and columns with variance = 0.

      Should not be NAs anymore.. But don't know.

      Still, the heat map looks very black, and the row clusters seams hard to interpret?

      Screen Shot 2014-02-16 at 16.20.05.pdf

      library(clusterGenomics)
      data <- read.table(file = "~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", header = FALSE, skip = 1, sep = "\t")

      dim(data)

      test <- count.fields("~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", sep="\t")
      which(test != 295)

      header = scan("~/RNAseq/INFSTK-5010/Oblig1/NEJM_Web_Fig1data.txt", "", n = 295)
      colnames(data) = header
      fixdata <- data[-7401,-275]

      x <- data.matrix(fixdata[,-1:-2], rownames.force = NA)

      rownames(x) <- fixdata[,1]
      x[is.na(x)] = 0

      ind <- apply(x, 2, var) == 0
      x <- x[,!ind]
      ind <- apply(x, 1, var) == 0
      x <- x[!ind,]

      colclust <- hclust(as.dist(1-cor(x, method="pearson")), method="average")

      rowclust <- hclust(as.dist(1-cor(t(x), method="pearson")), method="average")

      z <- x[rev(rowclust$labels[rowclust$order]), colclust$labels[colclust$order]]

      plotHeatmap(z, fast = TRUE)

      res = part(t(x), B=10, Kmax=10, minSize=40, dist.method="cor")

      plotTreeCol(clust=colclust, groups=res$lab.hatK[colclust$order])

      res2 = part(x, B=10, Kmax=10, minSize=40, dist.method="cor")

      plotTreeRow(clust=rowclust, groups=res2$lab.hatK[rowclust$order])

      groups = cutree(colclust, k=3)

      groups2 = cutree(colclust, h=2)

      comparison <- cbind(res$lab.hatK, groups)

      colnames(comparison) <- c("PART", "cutree")

      test <- ifelse(comparison[,1]==comparison[,2], 1,NA)

      table(is.na(test))["TRUE"]

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        This is because ~95% of the values are no more than 10% away from 0 after being normalized. Do a "hist(x)" to see this.

        I'd never heard of the "clusterGenomics" package before. I guess the treecutting part is interesting.

        Comment

        • sindrle
          Senior Member
          • Aug 2013
          • 266

          #5
          Thanks for input, it was what I thought, but it don't look like the one in the paper...

          I also liked the tree cutting!

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by SEQadmin2


            I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

            Here are nine questions we think about, in roughly the order they matter, before...
            06-18-2026, 07:11 AM
          • SEQadmin2
            From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
            by SEQadmin2


            Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


            The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
            ...
            06-02-2026, 10:05 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 06-17-2026, 06:09 AM
          0 responses
          40 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-09-2026, 11:58 AM
          0 responses
          102 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-05-2026, 10:09 AM
          0 responses
          123 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-04-2026, 08:59 AM
          0 responses
          114 views
          0 reactions
          Last Post SEQadmin2  
          Working...