View source: R/intersectRows.R
intersectRows | R Documentation |
Subset multiple batches so that they have the same number and order of rows.
intersectRows(..., subset.row = NULL, keep.all = FALSE)
... |
One or more matrix-like objects containing single-cell gene expression matrices. Alternatively, one or more SingleCellExperiment objects can be supplied. |
subset.row |
A vector specifying the subset of genes to retain.
Defaults to |
keep.all |
Logical scalar indicating whether the data should actually be subsetted to |
If any entry of ...
contains no row names or if the intersection is empty, an error is raised.
If all entries of ...
already have the same row names in the same order, this function is a no-op.
In such cases, subset.row
can be a character, integer or logical vector.
If entries of ...
do not have identical row names, subset.row
can only be a character vector.
Any other type will lead to an error as the interpretation of the subset is not well defined.
Setting keep.all=TRUE
option gives the same result as having subset.row=NULL
in the first place.
However, it is still useful for checking that subset.row
is a character vector.
This ensures that downstream applications can safely use subset.row
in conjunction with, e.g., correct.all=TRUE
for fastMNN
.
A list containing the row-subsetted contents of ...
, each of which have the same number and order of rows.
Aaron Lun
X <- rbind(A=c(1,2), B=c(3,4))
Y <- rbind(a=c(1,2), B=c(3,4))
intersectRows(X, Y) # Only B is retained.
# Error is raised when no genes are retained:
X <- rbind(A=c(1,2), B=c(3,4))
Y <- rbind(a=c(1,2), b=c(3,4))
try(intersectRows(X, Y))
# Error is raised for non-character subset.row
# when row names are not identical:
X <- rbind(A=c(1,2), B=c(3,4), C=c(5,6))
Y <- rbind(a=c(1,2), B=c(3,4), C=c(5,6))
intersectRows(X, Y)
intersectRows(X, Y, subset.row="B")
try(intersectRows(X, Y, subset.row=1))
# Setting keep.all=TRUE only checks but does not apply subset.row.
intersectRows(X, Y, subset.row="B", keep.all=TRUE)
try(intersectRows(X, Y, subset.row=1, keep.all=TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.