This is a test version of Biostars. For the public version, visit https://www.biostars.org.
xml file conversion in R

Hello everyone ^.^ I just learn R recently and met a problem. I have downloaded the data from TCGA and wanted to convert the xml file inside the unzip file. These are the code that I used:


1)

rm(list = ls())    
options(stringsAsFactors = F)

2)

setwd("C:/Users/User/Desktop/Bioinformatics")

3)

project <- "TCGA-LUAD"
clinicaldir <- "./Samples/Clinicaldata"

4)

library(XML)
library(methods)

5)

xmlFileNames <- dir(path=clinicaldir, full.names = T, pattern = "xml$", recursive = T)

6)

PatientClinicalList <- lapply(xmlFileNames, 
                              function(x){#x=xmlFileNames[1]
                                result <- xmlParse(file=x)
                                rootnode <- xmlRoot(result)
                                xmldataframe <- xmlToDataFrame(rootnode[2])
                                return(t(xmldataframe))})

7)

ClinicalDataList <- t(do.call(cbind, PatientClinicalList))

I got stuck at step 7, it shows

Error in (function (..., deparse.level = 1)  : 
      number of rows of matrices must match (see arg 2)

and I have no idea how to solve it.

Can anyone please help me solve it?

Thank you very much

r

Go through it step by step. Examine each member of PatientClinicalList and see where the cbind fails.

Extremely grateful for your reply. I've tried traceback() and debug(), still I could not locate the exact location which cause this error, erm... maybe I got the wrong code. Is there any code suggest?

Try t(do.call(cbind, PatientClinicalList[1:10])) etc until you can figure out where it breaks. This is a more basic/grounded approach to debugging that miight help nail the exact element.

Thank you very much for your help

0 answers

No answers yet.

Log in to answer this question.