Ok will try this and see
So I tried extracting information from a dataset on GEO onto R using
idx <- which(colnames(pData(gset[[1]])) %in%
c('AgeAtDiagnosis:ch1', 'Death:ch1', 'Gender:ch1',
'Grading:ch1','LymphNodesInvaded:ch1','LymphNodesRemoved:ch1',
'OverallSurvival_months:ch1', 'pM:ch', 'pN:ch', 'pT:ch',
'RectumOrColon:ch1 ', 'Rezidiv:ch1',
'TumorFreeSurvival_months:ch1','TumorLocalization:ch1'))
metadata <- data.frame(pData(gset[[1]])[,idx],
row.names = rownames(pData(gset[[1]])))
I needed to extract 14 columns from my data set but R only extracted 8. I have re-tried this a number of times but get the same result. How do I obtain the remaining 4 columns? Also, instead of generating the actual values for 'Grading', I obtained the value 'character'. Please how do I solve this?
1 answer
Please check the values of
colnames(pData(gset[[1]]))
idx
Then you should be able to solve the problem.
Kevin
I tried this and it seems it was supposed to generate the columns I requested (I am new with R so am not too sure). Wish I could share the image.
why don't you copy & paste the output of the two lines of code that Kevin posted?
Ok... So idx gave this response:
idx [1] 47 48 49 50 51 52 53 57 [9] 58 59 60 And colnames(pData(gset[[1]])) yielded this: "data_row_count"
[47] "AgeAtDiagnosis:ch1"
[48] "Death:ch1"
[49] "Gender:ch1"
[50] "Grading:ch1"
[51] "LymphNodesInvaded:ch1"
[52] "LymphNodesRemoved:ch1"
[53] "OverallSurvival_months:ch1"
[54] "pM:ch1"
[55] "pN:ch1"
[56] "pT:ch1"
[57] "RectumOrColon:ch1"
[58] "Rezidiv:ch1"
[59] "TumorFreeSurvival_months:ch1" [60] "TumorLocalization:ch1"
[61] "UICC:ch1"
colnames(pData(gset[[1]])) also yielded this
"characteristics_ch1"
[11] "characteristics_ch1.1"
[12] "characteristics_ch1.2"
[13] "characteristics_ch1.3"
[14] "characteristics_ch1.4"
[15] "characteristics_ch1.5"
[16] "characteristics_ch1.6"
[17] "characteristics_ch1.7"
[18] "characteristics_ch1.8"
[19] "characteristics_ch1.9"
[20] "characteristics_ch1.10"
[21] "characteristics_ch1.11"
[22] "characteristics_ch1.12"
[23] "characteristics_ch1.13"
[24] "characteristics_ch1.14"
(Sorry the data is long so I just took out the salient ones)
And also with regards with to my second question.. "Grading" column generated 'character' as the values for the metadata character character character character character character character
And thirdly, I noticed that not all the values with NA were discarded using
discard <- apply(metadata, 1, function(x) any( is.na(x) ))
metadata <- metadata[!discard,]
Thanks.
The output of
colnames(pData(gset[[1]]))
, does not seem correct. Can you show the unfiltered version?
Also, these three will not match:
'pM:ch', 'pN:ch', 'pT:ch'
You need to add a '1'
colnames(pData(gset[[1]]))
[1] "title"
[2] "geo_accession"
[3] "status"
[4] "submission_date"
[5] "last_update_date"
[6] "type"
[7] "channel_count"
[8] "source_name_ch1"
[9] "organism_ch1"
[10] "characteristics_ch1"
[11] "characteristics_ch1.1"
[12] "characteristics_ch1.2"
[13] "characteristics_ch1.3"
[14] "characteristics_ch1.4"
[15] "characteristics_ch1.5"
[16] "characteristics_ch1.6"
[17] "characteristics_ch1.7"
[18] "characteristics_ch1.8"
[19] "characteristics_ch1.9"
[20] "characteristics_ch1.10"
[21] "characteristics_ch1.11"
[22] "characteristics_ch1.12"
[23] "characteristics_ch1.13"
[24] "characteristics_ch1.14"
[25] "molecule_ch1"
[26] "extract_protocol_ch1"
[27] "extract_protocol_ch1.1"
[28] "label_ch1"
[29] "label_protocol_ch1"
[30] "taxid_ch1"
[31] "hyb_protocol"
[32] "scan_protocol"
[33] "description"
[34] "data_processing"
[35] "platform_id"
[36] "contact_name"
[37] "contact_email"
[38] "contact_phone"
[39] "contact_department"
[40] "contact_institute"
[41] "contact_address"
[42] "contact_city"
[43] "contact_zip/postal_code"
[44] "contact_country"
[45] "supplementary_file"
[46] "data_row_count"
[47] "AgeAtDiagnosis:ch1"
[48] "Death:ch1"
[49] "Gender:ch1"
[50] "Grading:ch1"
[51] "LymphNodesInvaded:ch1"
[52] "LymphNodesRemoved:ch1"
[53] "OverallSurvival_months:ch1"
[54] "pM:ch1"
[55] "pN:ch1"
[56] "pT:ch1"
[57] "RectumOrColon:ch1"
[58] "Rezidiv:ch1"
[59] "TumorFreeSurvival_months:ch1"
[60] "TumorLocalization:ch1"
[61] "UICC:ch1"
idx [1] 47 48 49 50 51 52 53 57 [9] 58 59 60
For PM etc, I tried with ch1 but I got an error response. However, ch gave an accepted response. Thanks.
Log in to answer this question.
Please use
ADD COMMENT/ADD REPLYwhen responding to existing comments to keep threads logically organized.SUBMIT ANSWERis for new answers to the original question.As you are not helping me, I can no longer help you further at this moment. Each time that you encounter an error, you need to show the error and the commands that you are running, and also the contents of your data.
Sorry. Hope to explain myself better in future. So I was wondering why the discard function does not delete the NA values in the dataset:
This is the output I had (I selected the columns of concern):
Thanks
I do not know what you are trying to now do. Originally, you were trying to select columns from the pData (metadata)