Title: | A Service for Tidy Transcriptomics Software Suite |
---|---|
Description: | It provides generic methods that are used by more than one package, avoiding conflicts. This package will be imported by 'tidySingleCellExperiment' and 'tidyseurat'. |
Authors: | Stefano Mangiola [aut, cre] |
Maintainer: | Stefano Mangiola <[email protected]> |
License: | GPL-3 |
Version: | 0.4.1 |
Built: | 2024-11-02 04:27:41 UTC |
Source: | https://github.com/stemangiola/ttservice |
Combine cells into groups based on shared variables and aggregate feature counts.
aggregate_cells( .data, .sample = NULL, slot = "data", assays = NULL, aggregation_function = Matrix::rowSums, ... )
aggregate_cells( .data, .sample = NULL, slot = "data", assays = NULL, aggregation_function = Matrix::rowSums, ... )
.data |
A tidySingleCellExperiment object |
.sample |
A vector of variables by which cells are aggregated |
slot |
The slot to which the function is applied |
assays |
The assay to which the function is applied |
aggregation_function |
The method of cell-feature value aggregation |
... |
Used for future extendibility |
A tibble object
print("pbmc_small |> aggregate_cells(c(groups, ident), assays = \"counts\")")
print("pbmc_small |> aggregate_cells(c(groups, ident), assays = \"counts\")")
This is an efficient implementation of the common pattern of 'do.call(rbind, dfs)' or 'do.call(cbind, dfs)' for binding many data frames into one.
This is an efficient implementation of the common pattern of 'do.call(rbind, dfs)' or 'do.call(cbind, dfs)' for binding many data frames into one.
bind_rows(..., .id = NULL, add.cell.ids = NULL) bind_cols(..., .id = NULL)
bind_rows(..., .id = NULL, add.cell.ids = NULL) bind_cols(..., .id = NULL)
... |
Data frames to combine. Each argument can either be a data frame, a list that could be a data frame, or a list of data frames. When row-binding, columns are matched by name, and any missing columns will be filled with NA. When column-binding, rows are matched by position, so all data frames must have the same number of rows. To match by value, not position, see mutate-joins. |
.id |
Data frame identifier. When '.id' is supplied, a new column of identifiers is created to link each row to its original data frame. The labels are taken from the named arguments to 'bind_rows()'. When a list of data frames is supplied, the labels are taken from the names of the list. If no names are found a numeric sequence is used instead. |
add.cell.ids |
from Seurat 3.0 A character vector of length(x = c(x, y)). Appends the corresponding values to the start of each objects' cell names. |
The output of 'bind_rows()' will contain a column if that column appears in any of the inputs.
The output of 'bind_rows()' will contain a column if that column appears in any of the inputs.
'bind_rows()' and 'bind_cols()' return the same type as the first input, either a data frame, 'tbl_df', or 'grouped_df'.
'bind_rows()' and 'bind_cols()' return the same type as the first input, either a data frame, 'tbl_df', or 'grouped_df'.
print("small_pbmc |> bind_rows(small_pbmc)") print("small_pbmc |> bind_cols(annotation_column)")
print("small_pbmc |> bind_rows(small_pbmc)") print("small_pbmc |> bind_cols(annotation_column)")
join_features() extracts and joins information for specific features
join_features( .data, features = NULL, all = FALSE, exclude_zeros = FALSE, shape = "long", ... )
join_features( .data, features = NULL, all = FALSE, exclude_zeros = FALSE, shape = "long", ... )
.data |
A tidy SingleCellExperiment object |
features |
A vector of feature identifiers to join |
all |
If TRUE return all |
exclude_zeros |
If TRUE exclude zero values |
shape |
Format of the returned table "long" or "wide" |
... |
Parameters to pass to join wide, i.e. assay name to extract feature abundance from and gene prefix, for shape="wide" |
This function extracts information for specified features and returns the information in either long or wide format.
A 'tbl' containing the information.for the specified features
print("this is a method generics Example is not applicable") # <object> |> join_features(features=c("HLA-DRA", "LYZ"))
print("this is a method generics Example is not applicable") # <object> |> join_features(features=c("HLA-DRA", "LYZ"))
This function maps R objects to plotly.js,
an (MIT licensed) web-based interactive charting library. It provides
abstractions for doing common things (e.g. mapping data values to
fill colors (via color
) or creating animations (via frame
)) and sets
some different defaults to make the interface feel more 'R-like'
(i.e., closer to plot()
and ggplot2::qplot()
).
plot_ly( data = data.frame(), ..., type = NULL, name = NULL, color = NULL, colors = NULL, alpha = NULL, stroke = NULL, strokes = NULL, alpha_stroke = 1, size = NULL, sizes = c(10, 100), span = NULL, spans = c(1, 20), symbol = NULL, symbols = NULL, linetype = NULL, linetypes = NULL, split = NULL, frame = NULL, width = NULL, height = NULL, source = "A" )
plot_ly( data = data.frame(), ..., type = NULL, name = NULL, color = NULL, colors = NULL, alpha = NULL, stroke = NULL, strokes = NULL, alpha_stroke = 1, size = NULL, sizes = c(10, 100), span = NULL, spans = c(1, 20), symbol = NULL, symbols = NULL, linetype = NULL, linetypes = NULL, split = NULL, frame = NULL, width = NULL, height = NULL, source = "A" )
data |
A data frame (optional) or crosstalk::SharedData object. |
... |
Arguments (i.e., attributes) passed along to the trace |
type |
A character string specifying the trace type (e.g. |
name |
Values mapped to the trace's name attribute. Since a trace can
only have one name, this argument acts very much like |
color |
Values mapped to relevant 'fill-color' attribute(s)
(e.g. fillcolor,
marker.color,
textfont.color, etc.).
The mapping from data values to color codes may be controlled using
|
colors |
Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"),
or a vector of colors to interpolate in hexadecimal "#RRGGBB" format,
or a color interpolation function like |
alpha |
A number between 0 and 1 specifying the alpha channel applied to |
stroke |
Similar to |
strokes |
Similar to |
alpha_stroke |
Similar to |
size |
(Numeric) values mapped to relevant 'fill-size' attribute(s)
(e.g., marker.size,
textfont.size,
and error_x.width).
The mapping from data values to symbols may be controlled using
|
sizes |
A numeric vector of length 2 used to scale |
span |
(Numeric) values mapped to relevant 'stroke-size' attribute(s)
(e.g.,
marker.line.width,
line.width for filled polygons,
and error_x.thickness)
The mapping from data values to symbols may be controlled using
|
spans |
A numeric vector of length 2 used to scale |
symbol |
(Discrete) values mapped to marker.symbol.
The mapping from data values to symbols may be controlled using
|
symbols |
A character vector of pch values or symbol names. |
linetype |
(Discrete) values mapped to line.dash.
The mapping from data values to symbols may be controlled using
|
linetypes |
A character vector of |
split |
(Discrete) values used to create multiple traces (one trace per value). |
frame |
(Discrete) values used to create animation frames. |
width |
Width in pixels (optional, defaults to automatic sizing). |
height |
Height in pixels (optional, defaults to automatic sizing). |
source |
a character string of length 1. Match the value of this string
with the source argument in |
Unless type
is specified, this function just initiates a plotly
object with 'global' attributes that are passed onto downstream uses of
add_trace()
(or similar). A formula must always be used when
referencing column name(s) in data
(e.g. plot_ly(mtcars, x = ~wt)
).
Formulas are optional when supplying values directly, but they do
help inform default axis/scale titles
(e.g., plot_ly(x = mtcars$wt)
vs plot_ly(x = ~mtcars$wt)
)
Carson Sievert
https://plotly-r.com/overview.html
For initializing a plotly-geo object: plot_geo()
For initializing a plotly-mapbox object: plot_mapbox()
For translating a ggplot2 object to a plotly object: ggplotly()
For modifying any plotly object: layout()
, add_trace()
, style()
For linked brushing: highlight()
For arranging multiple plots: subplot()
, crosstalk::bscols()
For inspecting plotly objects: plotly_json()
For quick, accurate, and searchable plotly.js reference: schema()
## Not run: # plot_ly() tries to create a sensible plot based on the information you # give it. If you don't provide a trace type, plot_ly() will infer one. plot_ly(economics, x = ~pop) plot_ly(economics, x = ~date, y = ~pop) # plot_ly() doesn't require data frame(s), which allows one to take # advantage of trace type(s) designed specifically for numeric matrices plot_ly(z = ~volcano) plot_ly(z = ~volcano, type = "surface") # plotly has a functional interface: every plotly function takes a plotly # object as it's first input argument and returns a modified plotly object add_lines(plot_ly(economics, x = ~date, y = ~unemploy/pop)) # To make code more readable, plotly imports the pipe operator from magrittr economics %>% plot_ly(x = ~date, y = ~unemploy/pop) %>% add_lines() # Attributes defined via plot_ly() set 'global' attributes that # are carried onto subsequent traces, but those may be over-written plot_ly(economics, x = ~date, color = I("black")) %>% add_lines(y = ~uempmed) %>% add_lines(y = ~psavert, color = I("red")) # Attributes are documented in the figure reference -> https://plotly.com/r/reference # You might notice plot_ly() has named arguments that aren't in this figure # reference. These arguments make it easier to map abstract data values to # visual attributes. p <- plot_ly(palmerpenguins::penguins, x = ~bill_length_mm, y = ~body_mass_g) add_markers(p, color = ~bill_depth_mm, size = ~bill_depth_mm) add_markers(p, color = ~species) add_markers(p, color = ~species, colors = "Set1") add_markers(p, symbol = ~species) add_paths(p, linetype = ~species) ## End(Not run)
## Not run: # plot_ly() tries to create a sensible plot based on the information you # give it. If you don't provide a trace type, plot_ly() will infer one. plot_ly(economics, x = ~pop) plot_ly(economics, x = ~date, y = ~pop) # plot_ly() doesn't require data frame(s), which allows one to take # advantage of trace type(s) designed specifically for numeric matrices plot_ly(z = ~volcano) plot_ly(z = ~volcano, type = "surface") # plotly has a functional interface: every plotly function takes a plotly # object as it's first input argument and returns a modified plotly object add_lines(plot_ly(economics, x = ~date, y = ~unemploy/pop)) # To make code more readable, plotly imports the pipe operator from magrittr economics %>% plot_ly(x = ~date, y = ~unemploy/pop) %>% add_lines() # Attributes defined via plot_ly() set 'global' attributes that # are carried onto subsequent traces, but those may be over-written plot_ly(economics, x = ~date, color = I("black")) %>% add_lines(y = ~uempmed) %>% add_lines(y = ~psavert, color = I("red")) # Attributes are documented in the figure reference -> https://plotly.com/r/reference # You might notice plot_ly() has named arguments that aren't in this figure # reference. These arguments make it easier to map abstract data values to # visual attributes. p <- plot_ly(palmerpenguins::penguins, x = ~bill_length_mm, y = ~body_mass_g) add_markers(p, color = ~bill_depth_mm, size = ~bill_depth_mm) add_markers(p, color = ~species) add_markers(p, color = ~species, colors = "Set1") add_markers(p, symbol = ~species) add_paths(p, linetype = ~species) ## End(Not run)