R microarray analysis : Trouble with an exercise
1
2
Entering edit mode
8.0 years ago
giroudpaul ▴ 70

Hello, I'm trying to understand how to analyze microarray data with R and Bioconductor. I found this quite nice and complete course for debutant (both for R and microarray analysis) : Link

However, I'm stuck with "Exercise 8 : create a heat map of normalized intensities of the first 50 genes using ggplot()" in the "Tutorial: Comparing two groups of samples"

So briefly, I came to the point where I have RMA normalized expression data in a data matrix, obtained with :

data = ReadAffy(celfile.path=celpath)
data.rma = rma(data)
data.matrix = exprs(data.rma)

Then, here is the part of code in the correction that block for me to create the heatmap :

#Exercise8: create a heat map of the first 50 genes using ggplot()
sampleNames = vector()
featureNames = vector()
heatlogs = vector()
for (i in 1:6)
{
sampleNames = c(sampleNames,rep(ph@data[i,1],50))
featureNames = c(featureNames,rownames(data.matrix[100:150,]))
heatlogs = c(heatlogs,data.matrix[100:150,i])
}
heatData = data.frame(norm_logInt=heatlogs,sampleName=sampleNames,featureName=featureNames)
dataHeat = ggplot(heatData, aes(sampleName,featureName))
dataHeat + geom_tile(aes(fill=norm_logInt)) + 
scale_fill_gradient(low="green", high="red")

More precisely, it's the heatData that don't work, returning this error :

Error in data.frame(norm_logInt = heatlogs, sampleName = sampleNames,  : 
  arguments imply differing number of rows : 306, 300

So I kind of understand what is happening here, I have between sampleNames, featureNames and heatlogs a different number of rows. However, I can't figure out where or what is the probleme above this

In order for you to see them :

> featureNames
  [1] "245000_at" "245001_at" "245002_at" "245003_at" "245004_at" "245005_at"
  [7] "245006_at" "245007_at" "245008_at" "245009_at" "245010_at" "245011_at"
 [13] "245012_at" "245013_at" "245014_at" "245015_at" "245016_at" "245017_at"
 [19] "245018_at" "245019_at" "245020_at" "245021_at" "245022_at" "245023_at"
 [25] "245024_at" "245025_at" "245026_at" "245027_at" "245028_at" "245029_at"
 [31] "245030_at" "245031_at" "245032_at" "245033_at" "245034_at" "245035_at"
 [37] "245036_at" "245037_at" "245038_at" "245039_at" "245040_at" "245041_at"
 [43] "245042_at" "245043_at" "245044_at" "245045_at" "245046_at" "245047_at"
 [49] "245048_at" "245049_at" "245050_at" "245000_at" "245001_at" "245002_at"
 [55] "245003_at" "245004_at" "245005_at" "245006_at" "245007_at" "245008_at"
 [61] "245009_at" "245010_at" "245011_at" "245012_at" "245013_at" "245014_at"
 [67] "245015_at" "245016_at" "245017_at" "245018_at" "245019_at" "245020_at"
 [73] "245021_at" "245022_at" "245023_at" "245024_at" "245025_at" "245026_at"
 [79] "245027_at" "245028_at" "245029_at" "245030_at" "245031_at" "245032_at"
 [85] "245033_at" "245034_at" "245035_at" "245036_at" "245037_at" "245038_at"
 [91] "245039_at" "245040_at" "245041_at" "245042_at" "245043_at" "245044_at"
 [97] "245045_at" "245046_at" "245047_at" "245048_at" "245049_at" "245050_at"
[103] "245000_at" "245001_at" "245002_at" "245003_at" "245004_at" "245005_at"
[109] "245006_at" "245007_at" "245008_at" "245009_at" "245010_at" "245011_at"
[115] "245012_at" "245013_at" "245014_at" "245015_at" "245016_at" "245017_at"
[121] "245018_at" "245019_at" "245020_at" "245021_at" "245022_at" "245023_at"
[127] "245024_at" "245025_at" "245026_at" "245027_at" "245028_at" "245029_at"
[133] "245030_at" "245031_at" "245032_at" "245033_at" "245034_at" "245035_at"
[139] "245036_at" "245037_at" "245038_at" "245039_at" "245040_at" "245041_at"
[145] "245042_at" "245043_at" "245044_at" "245045_at" "245046_at" "245047_at"
[151] "245048_at" "245049_at" "245050_at" "245000_at" "245001_at" "245002_at"
[157] "245003_at" "245004_at" "245005_at" "245006_at" "245007_at" "245008_at"
[163] "245009_at" "245010_at" "245011_at" "245012_at" "245013_at" "245014_at"
[169] "245015_at" "245016_at" "245017_at" "245018_at" "245019_at" "245020_at"
[175] "245021_at" "245022_at" "245023_at" "245024_at" "245025_at" "245026_at"
[181] "245027_at" "245028_at" "245029_at" "245030_at" "245031_at" "245032_at"
[187] "245033_at" "245034_at" "245035_at" "245036_at" "245037_at" "245038_at"
[193] "245039_at" "245040_at" "245041_at" "245042_at" "245043_at" "245044_at"
[199] "245045_at" "245046_at" "245047_at" "245048_at" "245049_at" "245050_at"
[205] "245000_at" "245001_at" "245002_at" "245003_at" "245004_at" "245005_at"
[211] "245006_at" "245007_at" "245008_at" "245009_at" "245010_at" "245011_at"
[217] "245012_at" "245013_at" "245014_at" "245015_at" "245016_at" "245017_at"
[223] "245018_at" "245019_at" "245020_at" "245021_at" "245022_at" "245023_at"
[229] "245024_at" "245025_at" "245026_at" "245027_at" "245028_at" "245029_at"
[235] "245030_at" "245031_at" "245032_at" "245033_at" "245034_at" "245035_at"
[241] "245036_at" "245037_at" "245038_at" "245039_at" "245040_at" "245041_at"
[247] "245042_at" "245043_at" "245044_at" "245045_at" "245046_at" "245047_at"
[253] "245048_at" "245049_at" "245050_at" "245000_at" "245001_at" "245002_at"
[259] "245003_at" "245004_at" "245005_at" "245006_at" "245007_at" "245008_at"
[265] "245009_at" "245010_at" "245011_at" "245012_at" "245013_at" "245014_at"
[271] "245015_at" "245016_at" "245017_at" "245018_at" "245019_at" "245020_at"
[277] "245021_at" "245022_at" "245023_at" "245024_at" "245025_at" "245026_at"
[283] "245027_at" "245028_at" "245029_at" "245030_at" "245031_at" "245032_at"
[289] "245033_at" "245034_at" "245035_at" "245036_at" "245037_at" "245038_at"
[295] "245039_at" "245040_at" "245041_at" "245042_at" "245043_at" "245044_at"
[301] "245045_at" "245046_at" "245047_at" "245048_at" "245049_at" "245050_at"
> sampleNames
  [1] "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"  
 [11] "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"  
 [21] "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"  
 [31] "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"  
 [41] "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"   "wt1"  
 [51] "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"  
 [61] "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"  
 [71] "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"  
 [81] "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"  
 [91] "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"   "wt2"  
[101] "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"  
[111] "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"  
[121] "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"  
[131] "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"  
[141] "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"   "wt3"  
[151] "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1"
[161] "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1"
[171] "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1"
[181] "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1"
[191] "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1" "apum1"
[201] "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2"
[211] "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2"
[221] "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2"
[231] "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2"
[241] "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2" "apum2"
[251] "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3"
[261] "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3"
[271] "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3"
[281] "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3"
[291] "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3" "apum3"
> head(heatlogs)
245000_at 245001_at 245002_at 245003_at 245004_at 245005_at 
 6.644076 13.221866  9.406594 10.387840 11.354398  3.398136

Thank you for your help !

R ggplot microarray heatmap bioconductor • 1.9k views
ADD COMMENT
1
Entering edit mode

Have a think how many entries are there in data.matrix[100:150, i]

How many would there be in data.matrix[100:101, i] ?

ADD REPLY
2
Entering edit mode
8.0 years ago
Michael 54k

Please check out these changes:

....  
length(100:150)
[1] 51
length(100:150)*6
[1] 306
....

sampleNames = c(sampleNames,rep(ph@data[i,1],50)) # gives 50 elements
featureNames = c(featureNames,rownames(data.matrix[101:150,])) # yields 50 elements now:  
heatlogs = c(heatlogs,data.matrix[101:150,i]) # same here
ADD COMMENT
0
Entering edit mode

That was it ! Ok, I really need to improve my R skills before going deeper in the microarray analysis ! Thank you !

Edit, actually, to have it correct with the exercises, so in order to have 50 genes, and not 49, I just need to do this :

sampleNames = c(sampleNames,rep(ph@data[i,1],51))
featureNames = c(featureNames,rownames(data.matrix[100:150,]))
heatlogs = c(heatlogs,data.matrix[100:150,i])
ADD REPLY
0
Entering edit mode

I still think you're mixing up fences and fenceposts there. Or perhaps the exercise is.

ADD REPLY
0
Entering edit mode

What do you mean ? I just follow the exercise, because it was a nice step by step exercise, with quite good explanation of the code. But I can't really say if it's correct or not. Maybe you know better trainings ?

ADD REPLY

Login before adding your answer.

Traffic: 2519 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