forked from satijalab/seurat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/FastSNN
- Loading branch information
Showing
12 changed files
with
211 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,6 +306,44 @@ AddSamples <- function( | |
return(new.object) | ||
} | ||
|
||
|
||
|
||
#' Return a subset of the Seurat object. | ||
#' | ||
#' Creates a Seurat object containing only a subset of the cells in the | ||
#' original object. Forms a dataframe by fetching the variables in \code{vars.use}, then | ||
#' subsets it using \code{base::subset} with \code{predicate} as the filter. | ||
#' Returns the corresponding subset of the Seurat object. | ||
#' | ||
#' @param object Seurat object | ||
#' @param vars.use Variables to fetch for use in base::subset. Character vector. | ||
#' @param predicate String to be parsed into an R expression and evaluated as an input to base::subset. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' pbmc1 <- SubsetByPredicate(object = pbmc_small, | ||
#' vars.use = c("nUMI", "res.1"), | ||
#' predicate = "nUMI < 200 & res.1=='3'") | ||
#' pbmc1 | ||
#' | ||
SubsetByPredicate = function( | ||
object, | ||
vars.use, | ||
predicate | ||
){ | ||
if( typeof(vars.use) != "character"){ | ||
stop("predicate should be a character vector. It will be parsed in `subset` as an R expression.") | ||
} | ||
if( typeof(predicate) != "character"){ | ||
stop("vars.use should be a character vector. These variables will be passed to FetchData.") | ||
} | ||
df <- FetchData(object, vars.use) %>% as.data.frame | ||
cu <- df %>% subset(eval(parse(text=predicate))) %>% rownames | ||
object <- SubsetData(object, cells.use = cu) | ||
return( object ) | ||
} | ||
|
||
#' Return a subset of the Seurat object | ||
#' | ||
#' Creates a Seurat object containing only a subset of the cells in the | ||
|
@@ -725,7 +763,9 @@ WhichCells <- function( | |
if(accept.low >= accept.high) { | ||
stop("accept.low greater than or equal to accept.high") | ||
} | ||
set.seed(seed = random.seed) | ||
if (!is.na(x = random.seed)) { | ||
set.seed(seed = random.seed) | ||
} | ||
cells.use <- SetIfNull(x = cells.use, default = object@cell.names) | ||
ident <- SetIfNull(x = ident, default = unique(x = object@ident)) | ||
bad.remove.idents <- ident.remove[! (ident.remove %in% unique(x = object@ident))] | ||
|
@@ -1085,7 +1125,9 @@ AddMetaData <- function(object, metadata, col.name = NULL) { | |
colnames(x = metadata) <- col.name | ||
} | ||
cols.add <- colnames(x = metadata) | ||
meta.add <- metadata[rownames(x = object@meta.data), cols.add] | ||
#meta.add <- metadata[rownames(x = [email protected]), cols.add] | ||
meta.order <- match(rownames(object@meta.data), rownames(metadata)) | ||
meta.add <- metadata[meta.order, ] | ||
if (all(is.null(x = meta.add))) { | ||
stop("Metadata provided doesn't match the cells in this object") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.