Title: | An R Wrapper for 'TooManyCells' |
---|---|
Description: | An R wrapper for using 'TooManyCells', a command line program for clustering, visualizing, and quantifying cell clade relationships. See <https://gregoryschwartz.github.io/too-many-cells/> for more details. |
Authors: | Gregory W. Schwartz |
Maintainer: | Gregory W. Schwartz <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1.1 |
Built: | 2024-11-05 04:12:10 UTC |
Source: | https://github.com/gregoryschwartz/toomanycellsr |
This function will import some of the files resulting from a 'too-many-cells make-tree' run into R as data frames. Does not include cluster list. Look at the main tooManyCells function for the cluster list.
importResults(dir = "out")
importResults(dir = "out")
dir |
The output directory of a 'too-many-cells' run. |
A list of each output. Reads the following files, see https://gregoryschwartz.github.io/too-many-cells/ for more details: "dendrogram.svg", "clumpiness.pdf", "projection.pdf", "label_projection.pdf", "clumpiness.csv", "cluster_info.csv", "node_info.csv", and "cluster_diversity.csv".
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") inputLabels <- system.file("extdata", "labels.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) labelsDf = read.csv(inputLabels, header = TRUE) # Here we draw this small toy example with no filter or normalization, and # decrease the size of the branches and increase the size of the leaf nodes. # With non-toy real world single cell data, these options should not be # necessary. ## Not run: tooManyCells( mat, labels = labelsDf , args = c( "make-tree" , "--no-filter" , "--normalization", "NoneNorm" , "--draw-max-node-size", "40" , "--draw-max-leaf-node-size", "70" ) ) res = importResults("out") plot(res$treePlot, axes = FALSE) ## End(Not run)
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") inputLabels <- system.file("extdata", "labels.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) labelsDf = read.csv(inputLabels, header = TRUE) # Here we draw this small toy example with no filter or normalization, and # decrease the size of the branches and increase the size of the leaf nodes. # With non-toy real world single cell data, these options should not be # necessary. ## Not run: tooManyCells( mat, labels = labelsDf , args = c( "make-tree" , "--no-filter" , "--normalization", "NoneNorm" , "--draw-max-node-size", "40" , "--draw-max-leaf-node-size", "70" ) ) res = importResults("out") plot(res$treePlot, axes = FALSE) ## End(Not run)
This function will run 'too-many-cells' on a Matrix. Requires 'TooManyCells' to be installed (follow instructions at https://gregoryschwartz.github.io/too-many-cells/ ).
tooManyCells(mat, args = c("make-tree"), labels = NULL, output = "out", prior = NULL, docker = NULL, mounts = c())
tooManyCells(mat, args = c("make-tree"), labels = NULL, output = "out", prior = NULL, docker = NULL, mounts = c())
mat |
The input Matrix with gene row names and cell barcode column names. |
args |
The arguments to give to the command line program. See https://gregoryschwartz.github.io/too-many-cells/ for more information. Defaults to "make-tree". |
labels |
The input labels data frame with item (cell barcodes) and label (whatever labels you want to give them, such as tissue of origin, celltype, etc.) columns. Optional. |
output |
The output folder for the 'too-many-cells' process. Defaults to "out". |
prior |
The location of the tree that was already made (previous 'too-many-cells' output) so quick visual or pruning changes can be made without remaking the tree (can potentially save hours). |
docker |
If using 'too-many-cells' with docker, use this argument as the command to call. For instance, if version 0.2.1.0 was pulled from Docker Hub, set to "gregoryschwartz/too-many-cells:0.2.1.0". |
mounts |
Additional directories to mount if needed for docker. The 'prior' argument will automatically mount if specified. |
A list of each output, including the stdout. Reads the following files, see https://gregoryschwartz.github.io/too-many-cells/ for more details: "dendrogram.svg", "clumpiness.pdf", "projection.pdf", "label_projection.pdf", "clumpiness.csv", "cluster_info.csv", "node_info.csv", and "cluster_diversity.csv".
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") inputLabels <- system.file("extdata", "labels.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) labelsDf = read.csv(inputLabels, header = TRUE) # Here we draw this small toy example with no filter or normalization, and # decrease the size of the branches and increase the size of the leaf nodes. # With non-toy real world single cell data, these options should not be # necessary. ## Not run: res = tooManyCells( mat, labels = labelsDf , args = c( "make-tree" , "--no-filter" , "--normalization", "NoneNorm" , "--draw-max-node-size", "40" , "--draw-max-leaf-node-size", "70" ) ) plot(res$treePlot, axes = FALSE) res$stdout res$nodeInfo ## End(Not run)
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") inputLabels <- system.file("extdata", "labels.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) labelsDf = read.csv(inputLabels, header = TRUE) # Here we draw this small toy example with no filter or normalization, and # decrease the size of the branches and increase the size of the leaf nodes. # With non-toy real world single cell data, these options should not be # necessary. ## Not run: res = tooManyCells( mat, labels = labelsDf , args = c( "make-tree" , "--no-filter" , "--normalization", "NoneNorm" , "--draw-max-node-size", "40" , "--draw-max-leaf-node-size", "70" ) ) plot(res$treePlot, axes = FALSE) res$stdout res$nodeInfo ## End(Not run)
This function will fail gracefully instead of stopping the program with an error.
tryFunc(f, file)
tryFunc(f, file)
f |
The function to use. |
file |
The input file to be read. |
The imported data frame or NULL if an error occurred.
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") fail = tryFunc(read.csv, "fail.csv") fail success = tryFunc(read.csv, input) success
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") fail = tryFunc(read.csv, "fail.csv") fail success = tryFunc(read.csv, input) success
This function will write a Matrix from the Matrix library to a temporary directory containing matrix.mtx, genes.tsv, barcodes.tsv, and optionally a labels.csv file.
writeMatrixFiles(mat, labels = NULL)
writeMatrixFiles(mat, labels = NULL)
mat |
The input Matrix with gene row names and cell barcode column names. |
labels |
The input labels data frame with item (cell barcodes) and label (whatever labels you want to give them, such as tissue of origin, celltype, etc.) columns. Optional. |
None
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) writeMatrixFiles(mat)
input <- system.file("extdata", "mat.csv", package="TooManyCellsR") df = read.csv(input, row.names = 1, header = TRUE) mat = Matrix::Matrix(as.matrix(df), sparse = TRUE) writeMatrixFiles(mat)