waldronlab / MultiAssayExperiment

Bioconductor package for management of multi-assay data
https://waldronlab.io/MultiAssayExperiment/
69 stars 32 forks source link

fail gracefully or subset for partly infeasible row selection #194

Closed vjcitn closed 7 years ago

vjcitn commented 7 years ago

example(MultiAssayExperiment) myMultiAssayExperiment A MultiAssayExperiment object of 4 listed experiments with user-defined names and respective classes. Containing an ExperimentList class object of length 4: [1] Affy: ExpressionSet with 2 rows and 4 columns [2] Methyl450k: matrix with 2 rows and 5 columns [3] RNASeqGene: matrix with 3 rows and 4 columns [4] CNVgistic: RangedRaggedAssay with 5 rows and 3 columns Features: experiments() - obtain the ExperimentList instance ...

myMultiAssayExperiment[1:3,] Error: subscript contains out-of-bounds indices

Enter a frame number, or 0 to exit

1: myMultiAssayExperiment[1:3, ] 2: myMultiAssayExperiment[1:3, ] 3: .local(x, i, j, ..., drop = drop) 4: subsetByRow(x, i, ...) 5: subsetByRow(x, i, ...) 6: rowIds[subsetor] 7: rowIds[subsetor] 8: subset_List_by_List(x, i) 9: extractROWS(x[[k]], i[[k]]) 10: extractROWS(x[[k]], i[[k]]) 11: normalizeSingleBracketSubscript(i, x, allow.NAs = TRUE) 12: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, allow.NAs = a 13: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, allow.NAs = a 14: .subscript_error("subscript contains out-of-bounds indices")

but myMultiAssayExperiment["XIST", ] drops irrelevant experiments and succeeds

LiNk-NY commented 7 years ago

Hi Vince, @vjcitn R, by default, won't let you subset an object if the subsetting index is out of bounds. We try to maintain this behavior for integer vector subsetting. This is mostly useful for a head() type of subset.

For finer control, try using an IRanges::IntegerList:

myMultiAssayExperiment[IRanges::IntegerList(1:2, 1:2, 1, 1), ]

Note: This has a side effect of removing samples in the RangedRaggedAssay since all rows are taken into account when subsetting by the "rows" of a RangedRaggedAssay.

vjcitn commented 7 years ago

OK, that makes sense. Would you want to avoid the stack trace with a pre-check and hint? I can try to set up a patch...

On Wed, Mar 22, 2017 at 1:39 PM, Marcel Ramos notifications@github.com wrote:

Hi Vince, @vjcitn https://github.com/vjcitn R, by default, won't let you subset an object if the subsetting index is out of bounds. We try to maintain this behavior for integer vector subsetting. This is mostly useful for a head() type of subset.

For finer control, try using an IRanges::IntegerList:

myMultiAssayExperiment[IRanges::IntegerList(1:2, 1:2, 1, 1), ]

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/waldronlab/MultiAssayExperiment/issues/194#issuecomment-288479609, or mute the thread https://github.com/notifications/unsubscribe-auth/AEaOwpbcpuMQo9vqDefJ46hR0LgYOoHCks5roVy1gaJpZM4Mljxp .

LiNk-NY commented 7 years ago

That's a good idea. I will work on one.

LiNk-NY commented 7 years ago

I've added a check and a more descriptive error message. Is this what you had in mind? @vjcitn

vjcitn commented 7 years ago

yes, thanks!

On Wed, Mar 22, 2017 at 8:35 PM, Marcel Ramos notifications@github.com wrote:

I've added a check and a more descriptive error message. Is this what you had in mind? @vjcitn https://github.com/vjcitn

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/waldronlab/MultiAssayExperiment/issues/194#issuecomment-288582230, or mute the thread https://github.com/notifications/unsubscribe-auth/AEaOwphhP2XkoCRmqGVBJl8Zf1WqcrH7ks5rob5jgaJpZM4Mljxp .

LiNk-NY commented 7 years ago

Thank you for reporting!

lwaldron commented 7 years ago

Should it be max (abs (y)) in case user is using negative integer subsetting? Weird case I know.

On Mar 22, 2017 22:52, "Marcel Ramos" notifications@github.com wrote:

Thank you for reporting!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/waldronlab/MultiAssayExperiment/issues/194#issuecomment-288602462, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnDxsyZv3Ju1PAl3lEp6tN8Ul78wRNKks5rod5egaJpZM4Mljxp .

LiNk-NY commented 7 years ago

@lwaldron I think that negative integer subsetting is fair game for removing unwanted rows.

lwaldron commented 7 years ago

In that case I'd suggest adding the absolute value...

On Mar 23, 2017 11:00, "Marcel Ramos" notifications@github.com wrote:

I think that negative integer subsetting is fair game for removing unwanted observations.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/waldronlab/MultiAssayExperiment/issues/194#issuecomment-288746851, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnDxm6WG8GPZxvcDjz2qjnUEz7GAkIrks5rookCgaJpZM4Mljxp .

LiNk-NY commented 7 years ago

I mean that the out-of-bounds error only happens when the positive integers are used for subsetting. When negative integers are used, there is no error by default R behavior.

vec <- 1:5
vec[-6]

When you do subset by a negative integer, it works as intended:

rownames(myMultiAssayExperiment)
rownames(myMultiAssayExperiment[-3])
lwaldron commented 7 years ago

Thanks Marcel, I just learned something about base R integer subsetting!

On Mar 23, 2017 11:13, "Marcel Ramos" notifications@github.com wrote:

I mean that the out-of-bounds error only happens when the positive integers are used for subsetting. When negative integers are used, there is no error by default R behavior;

vec <- 1:5 vec[-6]

When you do subset by a negative integer, it works as intended:

rownames(myMultiAssayExperiment) rownames(myMultiAssayExperiment[-3])

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/waldronlab/MultiAssayExperiment/issues/194#issuecomment-288751204, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnDxl_7h1jVS7lFmCeudikyPx70GsPLks5roowPgaJpZM4Mljxp .