# Single Cell Analysis and Differential Expression

## Documentation for package ‘pagoda2’ version 1.0.11

- DESCRIPTION file.

## Help Pages

armaCor | armaCor - matrix column correlations. Allows faster matrix correlations with armadillo. Similar to cor() call, will calculate correlation between matrix columns
basicP2proc | Perform basic 'pagoda2' processing, i.e. adjust variance, calculate pca reduction, make knn graph, identify clusters with multilevel, and generate largeVis and tSNE embeddings.
basicP2web | Generate a 'pagoda2' web application from a 'Pagoda2' object
buildWijMatrix | Rescale the weights in an edge matrix to match a given perplexity. From 'largeVis', <https://github.com/elbamos/largeVis>
calcMulticlassified | Returns a list vector with the number of cells that are present in more than one selections in the provided p2 selection object
cellsPerSelectionGroup | Get the number of cells in each selection group
collapse.aspect.clusters | Collapse aspect patterns into clusters
compareClusterings | Compare two different clusterings provided as factors by plotting a normalised heatmap
extendedP2proc | Perform extended 'Pagoda2' processing. Generate organism specific GO environment and calculate pathway overdispersion.
factorFromP2Selection | Returns a factor of cell membership from a p2 selection object the factor only includes cells present in the selection. If the selection contains multiclassified cells an error is raised
factorListToMetadata | Converts a list of factors into 'pagoda2' metadata optionally filtering down to the cells present in the provided 'pagoda2' app.
factorToP2selection | Converts a names factor to a p2 selection object if colors are provided it assigns those, otherwise uses a rainbow palette
gene.vs.molecule.cell.filter | Filter cells based on gene/molecule dependency
generateClassificationAnnotation | Given a cell clustering (partitioning) and a set of user provided selections generate a cleaned up annotation of cluster groups that can be used for classification
get.control.geneset | Get a control geneset for cell scoring using the method described in Puram, Bernstein (Cell, 2018)
get.de.geneset | Generate differential expression genesets for the web app given a cell grouping by calculating DE sets between each cell set and everything else
getCellsInSelections | Returns all the cells that are in the designated selections. Given a pagoda2 selections object and the names of some selections in it returns the names of the cells that are in these selections removed any duplicates

getClusterLabelsFromSelection

Assign names to the clusters, given a clustering vector and a set of selections. This function will use a set of pagoda2 cell seletcion to identify the clusters in a a named factor. It is meant to be used to import user defined annotations that are defined as selections into a more formal categorization of cells that are defined by cluster. To help with this the function allows a percent of cells to have been classified in the selections into multiple groups, something which may be the result of the users making wrong selections. The percent of cells allows to be multiselected in any given group is defined by multiClassCutoff. Furthermore the method will assign each cluster to a selection only if the most popular cluster to the next most popular exceed the ambiguous.ratio in terms of cell numbers. If a cluster does not satisfy this condtiion it is not assigned.

getColorsFromP2Selection | Retrieves the colors of each selection from a p2 selection object as a names vector of strings
getIntExtNamesP2Selection | Get a mapping form internal to external names for the specified selection object
hierDiffToGenesets | Converts the output of hierarchical differential expression aspects into genesets that can be loaded into a 'pagoda2' web app to retrive the genes that make the geneset interactively
make.p2.app | Generate a Rook Server app from a 'Pagoda2' object. This generates a 'pagoda2' web object from a 'Pagoda2' object by automating steps that most users will want to run. This function is a wrapper about the 'pagoda2' web constructor. (Advanced users may wish to use that constructor directly.)
minMaxScale | Scale the designated values between the range of 0 and 1
namedNames | Get a vector of the names of an object named by the names themselves. This is useful with lapply when passing names of objects as it ensures that the output list is also named.
p2.generate.dr.go | Generate a GO environment for human for overdispersion analysis for the the back end
p2.generate.go | Generate a GO environment for the organism specified
p2.generate.human.go | Generate a GO environment for human for overdispersion analysis for the the back end
p2.generate.mouse.go | Generate a GO environment for mouse for overdispersion analysis for the the back end
p2.make.pagoda1.app | Create 'PAGODA1' web application from a 'Pagoda2' object 'PAGODA1' found here, with 'SCDE': <https://www.bioconductor.org/packages/release/bioc/html/scde.html>
p2.metadata.from.factor | Generate a list metadata structure that can be passed to a 'pagoda2' web object constructor as additional metadata given a named factor
p2.toweb.hdea | Generate a 'pagoda2' web object from a 'Pagoda2' object using hierarchical differential expression
p2ViewPagodaApp | p2ViewPagodaApp R6 class

pagoda.reduce.loading.redundancy

Collapse aspects driven by the same combinations of genes. (Aspects are some pattern across cells e.g. sequencing depth, or PC corresponding to an undesired process such as ribosomal pathway variation.) Examines PC loading vectors underlying the identified aspects and clusters of aspects based on a product of loading and score correlation (raised to corr.power). Clusters of aspects driven by the same genes are determined based on the parameter "distance.threshold".

pagoda.reduce.redundancy | Collapse aspects driven by similar patterns (i.e. separate the same sets of cells) Examines PC loading vectors underlying the identified aspects and clusters aspects based on score correlation. Clusters of aspects driven by the same patterns are determined based on the distance.threshold.
pagoda2WebApp | pagoda2WebApp class to create 'pagoda2' web applications via a Rook server
pagoda2WebApp-class | pagoda2WebApp class to create 'pagoda2' web applications via a Rook server
pagoda2WebApp_arrayToJSON | pagoda2WebApp_arrayToJSON
pagoda2WebApp_availableAspectsJSON | pagoda2WebApp_availableAspectsJSON
pagoda2WebApp_call | pagoda2WebApp_call
pagoda2WebApp_cellmetadataJSON | pagoda2WebApp_cellmetadataJSON
pagoda2WebApp_cellOrderJSON | pagoda2WebApp_cellOrderJSON
pagoda2WebApp_geneInformationJSON | pagoda2WebApp_geneInformationJSON
pagoda2WebApp_generateDendrogramOfGroups | Generate a dendrogram of groups
pagoda2WebApp_generateEmbeddingStructure | pagoda2WebApp_generateEmbeddingStructure
pagoda2WebApp_generateGeneKnnJSON | pagoda2WebApp_generateGeneKnnJSON
pagoda2WebApp_getCompressedEmbedding | pagoda2WebApp_getCompressedEmbedding
pagoda2WebApp_packCompressFloat64Array | pagoda2WebApp_packCompressFloat64Array
pagoda2WebApp_packCompressInt32Array | pagoda2WebApp_packCompressInt32Array
pagoda2WebApp_readStaticFile | pagoda2WebApp_readStaticFile
pagoda2WebApp_reducedDendrogramJSON | pagoda2WebApp_reducedDendrogramJSON
pagoda2WebApp_serializeToStaticFast | pagoda2WebApp_serializeToStaticFast
pagoda2WebApp_serverLog | pagoda2WebApp_serverLog
pagoda2WebApp_sparseMatList | pagoda2WebApp_sparseMatList
pathway.pc.correlation.distance | Calculate correlation distance between PC magnitudes given a number of target dimensions
plotMulticlassified | Plot multiclassified cells per selection as a percent barplot
plotOneWithValues | Plot the embedding of a 'Pagoda2' object with the given values
plotSelectionOverlaps | Get a dataframe and plot summarising overlaps between selection of a pagoda2 selection object ignore self overlaps
projectKNNs | Project a distance matrix into a lower-dimensional space. (from elbamos/largeVis)
read.10x.matrices | Quick loading of 10X CellRanger count matrices
read10xMatrix | This function reads a matrix generated by the 10x processing pipeline from the specified directory and returns it. It aborts if one of the required files in the specified directory do not exist.
readPagoda2SelectionAsFactor | Read a pagoda2 cell selection file and return it as a factor while removing any mutliclassified cells
readPagoda2SelectionFile | Reads a 'pagoda2' web app exported cell selection file exported as a list of list objects that contain the name of the selection, the color (as a hex string) and the identifiers of the individual cells
removeSelectionOverlaps | Remove cells that are present in more than one selection from all the selections they are in
score.cells.nb0 | Score cells by getting mean expression of genes in signatures
score.cells.puram | Puram, Bernstein (Cell, 2018) Score cells as described in Puram, Bernstein (Cell, 2018)
sgdBatches | Calculate the default number of batches for a given number of vertices and edges. The formula used is the one used by the 'largeVis' reference implementation. This is substantially less than the recommendation E * 10000 in the original paper.
show.app | Directly open the 'pagoda2' web application and view the 'p2web' application object from our R session
subsetSignatureToData | Subset a gene signature to the genes in the given matrix with optional warning if genes are missing
tp2c.view.pathways | View pathway or gene-weighted PCA 'Pagoda2' version of the function pagoda.show.pathways() Takes in a list of pathways (or a list of genes), runs weighted PCA, optionally showing the result.
validateSelectionsObject | Validates a pagoda2 selection object
webP2proc | Generate a 'pagoda2' web object
winsorize.matrix | Sets the ncol(mat)*trim top outliers in each row to the next lowest value same for the lowest outliers
writeGenesAsPagoda2Selection | Writes a list of genes as a gene selection that can be loaded in the web interface
writePagoda2SelectionFile | Writes a pagoda2 selection object as a p2 selection file that be be loaded to the web interface