[R] "subscript out of bounds" error when trying to make heatmap

Vining, Kelly Kelly.Vining at oregonstate.edu
Tue Jun 21 23:27:13 CEST 2011


I am having trouble outputting a presence/absence heatmap using the following R script:

source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/overLapper.R")

I can generate the heatmap graphic. I just can't sort my columns without getting an error.

The instructions I'm following are from the Bioconductor manual here:
http://manuals.bioinformatics.ucr.edu/home/R_BioCondManual#R_graphics_heat

The specific section of instructions I'm using is this:
•  Presence-Absence Matrices: to indentify memberships of items across large numbers of sample sets 

source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/overLapper.R") # Imports the required overLapper() function.
paMA <- overLapper(setlist=setlist, type="intersects", complexity=2)[[2]]; paMA[names(rev(sort(rowSums(paMA)))),] # Creates a presence-absence matrix of all items across their sample sets. In this matrix the presence information is indicated by ones and its rows are sorted by the presence frequencies. Alternative versions of the present-absent matrix can be returned by setting the 'type' argument to 1, 2 or 3.
library("gplots"); heatmap.2(paMA, trace="none", Colv="none", Rowv="none", dendrogram="none", col=c("white", "gray")) # Plots the present-absent matrix as heatmap.
rowSums(paMA) # Returns the presence frequencies of the items in the sample sets.
sapply(rownames(paMA), function(x) colnames(paMA)[paMA[x, ]==1]) # Returns for each item the names of sample sets where it is present. The opposite result for absent calls can be returned by changing '==1' to '==0'. 

MY INPUT/OUTPUT 

# My data set is seven columns of gene names

 head(setlist[1:3])
               BUD      MALE_CATKIN    FEMALE_CATKIN
1 POPTR_0001s00240 POPTR_0001s00240 POPTR_0001s00240
2 POPTR_0001s00320 POPTR_0001s00510 POPTR_0001s00260
3 POPTR_0001s00330 POPTR_0001s00700 POPTR_0001s00610
4 POPTR_0001s00610 POPTR_0001s00740 POPTR_0001s00700
5 POPTR_0001s00680 POPTR_0001s00950 POPTR_0001s00870
6 POPTR_0001s00700 POPTR_0001s01130 POPTR_0001s00950

# The error I'm getting is at this step
> paMA <- overLapper(setlist=setlist, type="intersects", complexity=2)[[2]];
> paMA[names(rev(sort(rowSums(paMA)))),]
Error: subscript out of bounds



More information about the R-help mailing list