This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error in strsplit(TCGABarcode, split = "-") : non-character argument

hi

I use TCGA Assembler2 for data integration.

when run below codes this error occurred: Error in strsplit(TCGABarcode, split = "-") : non-character argument

how solve this error?

TNX

inputDataList   <- vector("list",   5)
inputDataList[[1]]  <- list(Des = GeneExpData$Des, Data = GeneExpData$Data, dataType = "geneExp")
inputDataList[[2]]  <- list(Des = Methylation450_TSS1500_DHS$Des, Data = Methylation450_TSS1500_DHS$Data,   dataType = "methylation")
inputDataList[[3]]  <- list(Des = GeneLevelCNA$Des, Data = GeneLevelCNA$Data, dataType = "copyNumber")
inputDataList[[4]]  <- list(Des = RPPAData$Des, Data = RPPAData$Data,   dataType    = "protein_RPPA")
inputDataList[[5]]  <- list(Des = miRNASeqData$Des, Data = miRNASeqData$Data, dataType = "miRNAExp")
MergedData <- CombineMultiPlatformData(inputDataList = inputDataList)
r

this is a TCGABarcode sample: TCGA-A6-3807-01A.22

Do not add an answer unless you're answering the top level question. I've moved this to a comment now, but use Add Comment or Add Reply at the appropriate spot in the future.

class(TCGABarcode) ?

> class(TCGABarcode)

Error: object 'TCGABarcode' not found

ATPoint is asking if the sample you provided above is a string in R or you just typed in the object name and it rendered a string representation of a more complex object. class(xyz) shows what type of object xyz is.

Please understand the concept behind these clarifying questions, copy-pasting code verbatim never works.

From your error, it seems obvious that your environment when you ran the command in the question strsplit(TCGABarcode, split = "-") is not the same as your environment now, as the object TCGABarcode definitely existed in that environment while it doesn't exist now.

I'm sorry I am very amateur and recently I work with R I'm confused now Now I am trying to solve the problem, if not resolved will come back again. thank you for your attention

2 answers

We are passing some factors to strsplit, to reproduce:

strsplit("my-factor-text", split = "-")
# [[1]]
# [1] "my"     "factor" "text" 

strsplit(factor("my-factor-text"), split = "-")
# Error in strsplit(factor("my-factor-text"), split = "-") : 
#   non-character argument

I am guessing you are using the TCGA-Assembler-2 from GitHub. When creating the input object - inputDataList, your list contains factors, not character class.

yes. I am using the TCGA-Assembler-2 .

how solve this problem?

TNX in advance

  1. Use as.character() to convert an object from factor to character (string)
  2. Please use professional language and avoid jargon such as "TNX". Use the proper "Thanks" instead.

TCGABarcode is not a split-able character and probably a list if I interpret this code at the bottom correctly. Can you show the content of this variable?

Splitting a list:

tmp <- as.list(c("hi-ho", "foo-bar"))
sapply(tmp, function(x) strsplit(x, split="-"))

Log in to answer this question.