Closed vjcitn closed 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
.
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 .
That's a good idea. I will work on one.
I've added a check and a more descriptive error message. Is this what you had in mind? @vjcitn
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 .
Thank you for reporting!
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 .
@lwaldron I think that negative integer subsetting is fair game for removing unwanted rows.
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 .
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])
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 .
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