- Notifications
You must be signed in to change notification settings - Fork 21
cbind: unique/duplicated colnamesare left asis/made unique; read10xVisium: keep barcodes as colData; spatialCoords/<-: withDimnames argument#128
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
base:devel
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
cc934978d819903ddd2c3d8aabf6ac4bd0f1b4fad4fe40c8f28319038842c22fc2e6af253e5e40db2ad7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # spatialCoords ---------------------------------------------------------------- | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @importFrom SingleCellExperiment int_colData<- | ||
| #' @export | ||
| setMethod("spatialCoords", | ||
| "SpatialExperiment", | ||
| function(x, withDimnames=TRUE, ...) { | ||
| out <- int_colData(x)$spatialCoords | ||
| if (withDimnames) | ||
| rownames(out) <- colnames(x) | ||
| return(out) | ||
| }) | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @importFrom SingleCellExperiment int_colData<- | ||
| #' @export | ||
| setReplaceMethod("spatialCoords", | ||
| c("SpatialExperiment", "matrix"), | ||
| function(x, withDimnames=TRUE, ..., value) { | ||
| stopifnot( | ||
| is.numeric(value), | ||
| nrow(value) == ncol(x)) | ||
| new <- rownames(value) | ||
| if (!is.null(new) && withDimnames) { | ||
| if (!identical(new, colnames(x))) { | ||
| stop("Non-NULL 'rownames(value)' should be the", | ||
| " same as 'colnames(x)' for 'spatialCoords<-'.", | ||
| " Use 'withDimnames=FALSE' to force replacement.") | ||
| } | ||
| } | ||
| int_colData(x)$spatialCoords <- value | ||
| return(x) | ||
| } | ||
| ) | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @export | ||
| setReplaceMethod("spatialCoords", | ||
| c("SpatialExperiment", "NULL"), | ||
| function(x, withDimnames=TRUE, ..., value) { | ||
| `spatialCoords<-`(x, | ||
| withDimnames=withDimnames, ..., | ||
| value=matrix(numeric(), ncol(x), 0)) | ||
| } | ||
| ) | ||
| # spatialCoordsNames ----------------------------------------------------------- | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @importFrom SingleCellExperiment int_colData | ||
| #' @export | ||
| setMethod("spatialCoordsNames", | ||
| "SpatialExperiment", | ||
| function(x) colnames(int_colData(x)$spatialCoords)) | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @importFrom SingleCellExperiment int_colData<- | ||
| #' @export | ||
| setReplaceMethod("spatialCoordsNames", | ||
| c("SpatialExperiment", "character"), | ||
| function(x, value) { | ||
| colnames(int_colData(x)$spatialCoords) <- value | ||
| return(x) | ||
| } | ||
| ) | ||
| #' @rdname SpatialExperiment-methods | ||
| #' @export | ||
| setReplaceMethod("spatialCoordsNames", | ||
| c("SpatialExperiment", "NULL"), | ||
| function(x, value) { | ||
| value <- character() | ||
| `spatialCoordsNames<-`(x, value) | ||
| } | ||
| ) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a warning that I suppose is coming from the "matrix" instead of a "value"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I saw. But I don’t understand because it’s good locally. I’m on it…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed I don't get why, but have you tried something like:
c("SpatialExperiment", "value")?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's because the generic is defined as
setGeneric("spatialCoords<-", function(x, value, withDimnames=TRUE) standardGeneric("spatialCoords<-"))Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…the signature has to be classes, so “NULL” and “matrix” (not “value”) is correct. It’s saying the generic and methods don’t match. But I don’t see why not as they both have “value” in the function definition in the same order…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I saw that, I'm looking over the internet, but still I'm not able to understand the motivation for this warning.