Subsetting Range Summarized Experiment
1
0
Entering edit mode
Bine ▴ 40
@bine-23912
Last seen 3 days ago
UK

Dear all,

I am trying to subset my RangeSummarizedExperiment with se[, se$name == lung]. However, when doing so I keep getting this error: Error: logical subscript contains NAs

Does anyone has an idea how I can subset it nevertheless?

Thank you & Best Regards, Bine

SummarizedExperiment • 780 views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

You almost surely don't want to use lung, but instead "lung". In the former, you are saying that there is an object in your workspace called lung that contains the things you want to filter on. In the latter, you are saying that some of the rows in your colData object have "lung" in the name column, and you want to select those columns of your SummarizedExperiment object. In addition, you probably don't want to use equality == in this situation, but instead you want %in%, which is resistant to the existence of NA in your se$name column.

se.small <- se[,se$name %in% "lung"]
0
Entering edit mode

Hi James,

thanks for your answer. Sorry I forget the " " around lung in the post here, but did put it in my code. It is working now with %in%, that's great, thank you!

Can I ask you one other related question to subsetting of a Summarised Object - I would like to get rid of a column ("primary,site") in colData, but it seems not to work the usual way...

se.small[ , -which(names(se.small) %in% c("primary.site"))]

Do you know how I could do this?

Thank you, Bine

ADD REPLY
0
Entering edit mode
se.small[,!se.small$names %in% "primary.site"]
ADD REPLY
0
Entering edit mode

Thank you. But like this it removes all the values and everything is 0.

I should also mention that the structure is as below for this variable of colData:

Primary.site

Primary.site is a list.

Thank you!!!

ADD REPLY
1
Entering edit mode

Rereading your previous post, it's not clear if you want to get rid of a particular column of your colData slot, or if you want to filter on things that are in that column (which apparently is called 'primary_site', rather than 'primary.site').

If the former, you just replace the colData.

colData(se.small) <- colData(se.small)[, !names(colData(se.small)) %in% "primary_site"]

Or if it's as you seem to imply, that you don't want any of the values in se.small$names to be in any of the list items for primary_site, then you can use sapply

nam <- se.small$names
ind <- sapply(se.small$primary_site, function(x) any(x %in% nam))
se.small <- se.small[,!ind]
ADD REPLY
0
Entering edit mode

Yes, I just wanted to get rid of that column in colData, it worked with colData(se.small) <- colData(se.small)[, !names(colData(se.small)) %in% "primary_site"].

Thanks a lot !

ADD REPLY

Login before adding your answer.

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