subsetSamples: Subset Samples/observations from a data matrix

View source: R/base_package_functions.R View source: R/Package-Code5-Compiled.R

subsetSamplesR Documentation

Subset Samples/observations from a data matrix

Description

Quick function to subset samples/observations from a data matrix based on an annotation or characteristic. Can also pull out samples/observations by name with the option to order the rows by expression of a given sample.

Usage

subsetSamples(data, group, take.out, list, order.by = NULL, exact = F,
subset.by = "annotation")

Arguments

data

numeric data matrix with samples/observations in the columns and genes/variables in the rows

group

character string pointing to a column name in the annotations stored in params. Can also supply a custom vector the same length as the columns of the input matrix.

take.out

level or levels of the group vector supplied indicating the samples to be extracted

list

character vector of samples/observations to be pulled out of the data matrix for viewing

order.by

optional string equal to one of the colnames of the supplied data frame. Rows of output data matrix will be ordered according to the supplied sample from lowest to highest expression value.

exact

whether or not to search for exact or inexact matches of 'list' in 'data'. If exact = T (default) output will contain samples/observations that exactly match the list supplied. If set to FALSE, will search for inexact matches.

subset.by

whether to subset by an annotation stored in params$annotations ("annotation", default) or by the a list of names to search for in column names ("name")

Value

data matrix with the same number of rows as the input data matrix but subset for the specified samples

Author(s)

~~Alison Moss~~

Examples

##initiate parameters and set up annotations
initiate_params()
set_annotations(RAGP_annots)

##subset samples for SAN-Projecting cells
SAN.proj <- subsetSamples(RAGP_norm, group = "Connectivity", take.out = "SAN-Projecting")

##subset samples for cells with projection information
proj.ino <- subsetSamples(RAGP_norm, group = "Connectivity",
  take.out = c("SAN-Projecting", "Non-SAN-Projecting"))

axm323/dataVisEasy documentation built on Feb. 1, 2024, 11:53 p.m.