Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SummarizedExperiment::cbind #23

Open
tiagochst opened this issue Jun 12, 2019 · 3 comments
Open

SummarizedExperiment::cbind #23

tiagochst opened this issue Jun 12, 2019 · 3 comments

Comments

@tiagochst
Copy link

Hello,

this is just a suggestion. If a have to SE, with the same data, but one has a metadata column that the other does not have.

The package gives the following error:

Error in map_x_colnames_to_object_colnames(colnames(object)) : 
  the DataFrame objects to rbind must have the same number of columns

But instead of using a rbind wouldn't it be better to use a rbind.fill (https://www.rdocumentation.org/packages/plyr/versions/1.8.4/topics/rbind.fill)
in this part code

colData <- do.call(rbind, lapply(args, colData))

In that way, it will populate the metadata with NA and shows show a warning instead.
I am not sure if it was discussed before. Otherwise, it would be nice to specify more clearly that the problem is within the metadata.

Here is an example of the problem if we add year_to_death column.

nrows <- 200; ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)),
                     IRanges(floor(runif(200, 1e5, 1e6)), width=100),
                     strand=sample(c("+", "-"), 200, TRUE),
                     feature_id=sprintf("ID%03d", 1:200))
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
                     row.names=LETTERS[1:6])
rse <- SummarizedExperiment(assays=SimpleList(counts=counts),
                            rowRanges=rowRanges, colData=colData)

colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
                     years_to_death = 1:6,
                     row.names=LETTERS[1:6])
rse2 <- SummarizedExperiment(assays=SimpleList(counts=counts),
                            rowRanges=rowRanges, colData=colData)

SummarizedExperiment::cbind(rse2, rse)
@wjyzidane
Copy link

I got the same error. Is there a way to remove a specific column in ColData?

@lawremi
Copy link

lawremi commented Aug 2, 2019

Sure, just replace the column with NULL like you would do with an R data.frame:

colData(se)$foo <- NULL

In my opinion, the current behavior is fine. If there are inconsistencies in the metadata, the user should do something explicit. For consistency, safety, etc, cbind() should just do rbind() on the column metadata. Maybe there could be a merge() method that is more forgiving.

@wjyzidane
Copy link

wjyzidane commented Aug 2, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants