Skip to content

Commit

Permalink
adjust %<<+% for patchwork
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangpin committed May 24, 2024
1 parent 8ad4e0c commit a7e5e8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions R/internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
p <- p$data |> dplyr::group_split(.data$features) |>
lapply(function(i){
p$data <- i
p <- .add_class(p, "ggsc")
return(p)
})

Expand Down
10 changes: 8 additions & 2 deletions R/method-left_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ left_join.ggsc <- function(x, y, by = NULL, copy = FALSE, suffix=c("", ".y"), ..
#' add the external data frame to the ggsc object.
#' @rdname attacher
#' @param x ggsc object, the result of \code{sc_dim}, \code{sc_feature} and \code{sc_spatial}.
#' @param y a data.frame, which the first column should be a barcode id, which is similar with
#' the x$data$`.BarcodeID`. It also can have another column \code{features}.
#' @param y a data.frame, which should have a barcode id column named \code{.BarcodeID},
#' it is the same to the x$data$`.BarcodeID`. It also can have another column \code{features}.
#' @export
#' @return ggsc object
`%<<+%` <- function(x, y){
Expand All @@ -43,6 +43,12 @@ left_join.ggsc <- function(x, y, by = NULL, copy = FALSE, suffix=c("", ".y"), ..
"i" = "Did you accidentally put {.code %<<+%} on a new line?"
))
}
if (inherits(x, 'patchwork')){
x$patches$plots <- lapply(x$patches$plots, function(p){
p <- left_join(p, y)
return(p)}) |>
suppressMessages()
}
x <- left_join(x, y)
return(x)
}
4 changes: 2 additions & 2 deletions man/attacher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7e5e8a

Please sign in to comment.