-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bf AutoNumber.by.UMAP
- Loading branch information
Showing
7 changed files
with
66 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: Seurat.utils | ||
Title: Seurat.utils - utility functions for Seurat | ||
Version: 1.5.0 | ||
Version: 1.5.2 | ||
Authors@R: | ||
person("Abel", "Vertesy", , "[email protected]", role = c("aut", "cre")) | ||
Author: Abel Vertesy <[email protected]> [aut, cre] | ||
|
@@ -51,6 +51,6 @@ Imports: | |
Suggests: | ||
SoupX | ||
Encoding: UTF-8 | ||
Packaged: 2022-10-19 13:57:07 | ||
Packaged: 2022-10-19 17:47:22 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.0 |
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 |
---|---|---|
|
@@ -348,17 +348,21 @@ DimPlot.ClusterNames <- function(obj = combined.obj # Plot UMAP with Cluster nam | |
#' } | ||
#' @export | ||
AutoNumber.by.UMAP <- function(obj = combined.obj # Relabel cluster numbers along a UMAP (or tSNE) axis | ||
, dim = 1, swap= F, reduction="umap", res = "integrated_snn_res.0.5" ) { | ||
, dim = 1, swap= F, reduction="umap", res = "RNA_snn_res.0.5" ) { | ||
|
||
dim_name <- kppu(toupper(reduction),dim) | ||
coord.umap <- as.named.vector(FetchData(object = obj, vars = dim_name)) | ||
ls.perCl <- split(coord.umap, f = obj[[res]]) | ||
identX <- as.character([email protected][[res]]) | ||
|
||
ls.perCl <- split(coord.umap, f = identX) | ||
MedianClusterCoordinate <- unlapply(ls.perCl, median) | ||
|
||
OldLabel <- names(sort(MedianClusterCoordinate, decreasing = swap)) | ||
NewLabel <- as.character(0:(length(MedianClusterCoordinate) - 1)) | ||
NewMeta <- translate(vec = obj[[res]], oldvalues = OldLabel, newvalues = NewLabel) | ||
NewMeta <- translate(vec = identX, oldvalues = OldLabel, newvalues = NewLabel) | ||
NewMetaCol <- kpp(res,"ordered") | ||
iprint("NewMetaCol:",NewMetaCol) | ||
|
||
obj[[NewMetaCol]] <- NewMeta | ||
return(obj) | ||
} | ||
|
@@ -1583,10 +1587,9 @@ get.clustercomposition <- function(obj = combined.obj, ident = 'integrated_snn_r | |
#' remove.residual.small.clusters | ||
#' @description E.g.: after subsetting often some residual cells remain in clusters originally denfined in the full dataset. | ||
#' @param identitites Identities to scan for residual clusters | ||
#' @param obj | ||
#' @param obj Seurat object, Default: combined.obj | ||
#' @param max.cells Max number of cells in cluster to be removed. Default: 0.5% of the dataset | ||
#' @export | ||
#' @examples | ||
|
||
remove.residual.small.clusters <- function(identitites = GetOrderedClusteringRuns() | ||
, obj = combined.obj | ||
|
@@ -1623,7 +1626,6 @@ remove.residual.small.clusters <- function(identitites = GetOrderedClusteringRun | |
#' drop.levels.Seurat | ||
#' @description Drop levels in clustering vectors in metadata (e.g. after subsetting) | ||
#' @param obj Seurat object, Default: combined.obj | ||
#' @examples | ||
#' @export | ||
|
||
drop.levels.Seurat <- function(obj = combined.obj) { | ||
|
@@ -3464,9 +3466,16 @@ scBarplot.CellFractions <- function(obj = combined.obj | |
# _________________________________________________________________________________________________ | ||
#' @title scBarplot.CellsPerCluster | ||
#' @description Barplot the Fraction of cells per cluster. (dupl?) | ||
#' | ||
#' @param obj Seurat object, Default: combined.obj | ||
#' @param ident identity used, Default: 'cl.names.KnownMarkers.0.5' | ||
#' @param sort PARAM_DESCRIPTION, Default: F | ||
#' @param label True: displays cell count, but you can provide anything in a vector. | ||
#' @param palette Color palette. Default: glasbey. | ||
#' @param return_table Should it return the plotting data instead of the plot? | ||
#' @param ... Pass any other parameter to the internally called functions (most of them should work). | ||
#' @param sort Sort by cluster size? Default: F | ||
#' @param suffix File name suffix | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' if(interactive()){ | ||
|
@@ -3477,21 +3486,25 @@ scBarplot.CellFractions <- function(obj = combined.obj | |
|
||
scBarplot.CellsPerCluster <- function(ident = GetOrderedClusteringRuns()[1] | ||
, sort = F | ||
, label = T | ||
, label = list(T, 'percent')[[1]] | ||
, suffix = if (label == 'percent') 'percent' else NULL | ||
, palette = c("alphabet", "alphabet2", "glasbey", "polychrome", "stepped")[3] | ||
, obj = combined.obj | ||
, return_table = F | ||
, ...) { | ||
cell.per.cl <- obj[[ident]][,1] | ||
cell.per.cluster <- (table(cell.per.cl)) | ||
if (sort) cell.per.cluster <- sort(cell.per.cluster) | ||
lbl <- if (isFALSE(label)) NULL else if(isTRUE(label)) cell.per.cluster else label | ||
lbl <- if (isFALSE(label)) { NULL | ||
} else if (label == 'percent') { percentage_formatter(cell.per.cluster/sum(cell.per.cluster)) | ||
} else if (label == 'T') { cell.per.cluster | ||
} else label | ||
|
||
n.clusters <- length(cell.per.cluster) | ||
if (return_table) { | ||
cell.per.cluster | ||
} else { | ||
ggExpress::qbarplot(cell.per.cluster, subtitle = ident, suffix = ident | ||
ggExpress::qbarplot(cell.per.cluster, subtitle = ident, suffix = kpp(ident, suffix) | ||
, col = 1:n.clusters | ||
, xlab.angle = 45 | ||
, label = lbl | ||
|
@@ -5632,9 +5645,8 @@ IntersectWithExpressed <- function(genes, obj=combined.obj, genes.shown = 10) { | |
# _________________________________________________________________________________________________ | ||
#' seu.RemoveMetadata | ||
#' | ||
#' @param obj Seurat object | ||
#' @param obj Seurat object, Default: combined.obj | ||
#' @param cols_remove columns to remove | ||
#' @example # seu.RemoveMetadata() | ||
#' @export | ||
|
||
seu.RemoveMetadata <- function(obj = combined.obj | ||
|
@@ -5654,11 +5666,11 @@ seu.RemoveMetadata <- function(obj = combined.obj | |
|
||
# _________________________________________________________________________________________________ | ||
#' Percent.in.Trome | ||
#' @description Gene expression as fraction of all UMI's | ||
#' @description Gene expression as fraction of all UMI's | ||
#' @param obj Seurat object | ||
#' @param n.genes.barplot number of top genes shows | ||
#' @param width.barplot barplot width | ||
#' @return Seurat object | ||
#' @return Seurat object | ||
#' @export | ||
#' @examples # combined.obj <- Percent.in.Trome() | ||
|
||
|
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.