This is a test version of Biostars. For the public version, visit https://www.biostars.org.
subsetting of expressionSet

Hi I want to subset an expressionSet that includes samples from control,node negative and positive of breast cancer

I run this code

`eset <-my_eset[,my_eset$Disease== c("control","node negative breast cancer")]

but it didn't work well (some of samples dropped )

Thank you.

r bioconductor

1 answer

The problem is your logical evaluation. The following illustrates what I mean:

> test_seq <- seq(1:10)

> test_seq==c(1,3)
[1]  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

> test_seq==1 | test_seq==3
[1]  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

> test_seq[test_seq==1 | test_seq==3]
[1] 1 3

So to fix your code, it should use the | (logical or). Also, I assume you want to subset rows, so your subsetting command should be genedata[logical_expression, ] instead of genedata[, logical_expression] so your code should be: eset <- my_eset[my_eset$Disease == "control" | my_eset$Disease == "node negative breast cancer", ]

Log in to answer this question.