Skip to content

Commit

Permalink
updated shift() example, fixes #163
Browse files Browse the repository at this point in the history
  • Loading branch information
thackl committed Oct 15, 2023
1 parent 7a0b738 commit 2f74230
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
33 changes: 17 additions & 16 deletions R/shift.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
#' @param by shift each bin by this many bases. Single value or vector of the
#' same length as bins.
#' @examples
#' # Basic example plot
#' gggenomes(seqs = emale_seqs) |>
#' geom_seq() +
#' geom_bin_label()
#'
#' # All bins have been shifted 10000 basepaiers
#' gggenomes(seqs = emale_seqs) |>
#' shift(bins = everything(), by = 10000)
#' geom_seq() +
#' geom_bin_label()
#'
#' # Only RCC970_016B bin has been shifted for 5000 basepaiers
#' gggenomes(seqs = emale_seqs) |>
#' shift(bins = RCC970_016B, by = 5000, center = FALSE)
#' geom_seq() +
#' geom_bin_label()
#' p0 <- gggenomes(emale_genes, emale_seqs) +
#' geom_seq() + geom_gene()
#'
#' # Slide one bin left and one bin right
#' p1 <- p0 |> shift(2:3, by=c(-8000, 10000))
#'
#' # align all bins to a target gene
#' mcp <- emale_genes |>
#' filter(name == "MCP") |>
#' group_by(seq_id) |>
#' slice_head(n=1) # some have fragmented MCP gene, keep only first
#'
#' p2 <- p0 |> shift(all_of(mcp$seq_id), by= -mcp$start) +
#' geom_gene(data=genes(name=="MCP"), fill="#01b9af")
#'
#' library(patchwork)
#' p0 + p1 + p2
#' @export
shift <- function(x, bins=everything(), by=0, center=FALSE){
# split by bin_id and select bins
Expand Down
29 changes: 15 additions & 14 deletions man/shift.Rd

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

0 comments on commit 2f74230

Please sign in to comment.