Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
abel.vertesy committed Oct 25, 2023
1 parent 12abdf5 commit 2089f1b
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cff-version: 1.2.0
title: vertesy/Seurat.utils
version: v1.9.9
version: v2.0.0
message: >-
If you use this software, please cite it using these metadata.
type: software
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
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.9.9
Version: 2.0.0
Authors@R:
person("Abel", "Vertesy", , "[email protected]", role = c("aut", "cre"))
Author: Abel Vertesy <[email protected]> [aut, cre]
Expand Down Expand Up @@ -52,6 +52,6 @@ Imports:
Suggests:
SoupX
Encoding: UTF-8
Packaged: 2023-10-17 15:33:37.673196
Packaged: 2023-10-25 16:36:17.735738
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
2 changes: 1 addition & 1 deletion Development/Create_the_Seurat.utils_Package.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require('CodeAndRoll2')

# Setup ------------------------
PackageName = "Seurat.utils"
package.version = "1.9.9"
package.version = "2.0.0"
setwd("~/GitHub/Packages/")

RepositoryDir = kollapse("~/GitHub/Packages/", PackageName, "/")
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

S3method(drop.levels,Seurat)
S3method(plot,GeneExpHist)
S3method(plot,Metadata.Cor.Heatmap)
S3method(plot,Metadata.categ.pie)
Expand Down Expand Up @@ -71,6 +70,7 @@ export(check.genes)
export(clUMAP)
export(clip10Xcellname)
export(create.metadata.vector)
export(drop.levels.Seurat)
export(find_prefix_in_cell_IDs)
export(fix.orig.ident)
export(fixZeroIndexing.seurat)
Expand Down
27 changes: 14 additions & 13 deletions R/Seurat.Utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@
#'
#' @export

parallel.computing.by.future <- function(cores = 4, maxMemSize = 4000 * 1024^2) { # Run gc(), load multi-session computing and extend memory limits.
parallel.computing.by.future <- function(cores = 4, maxMemSize = 4000 * 1024^2, strategy = 'multicore') { # Run gc(), load multi-session computing and extend memory limits.
# https://satijalab.org/seurat/v3.0/future_vignette.html
cat(
"1. If you load futures before you finished using foreach loops,
"\n1. If you load futures before you finished using foreach loops,
NormalizeData inside a foreach loop fails (Error writing to connection)
-> I assume 'future' and 'doMC' are not compatible
2. If you setup computing on e.g. six cores, it runs 6 instances of R with the entire memory space copied.
If you run out of memory, the system starts using the SSD as memory, and it slows you down extremely extremely extremely.
-> Therefore it is important to clean up the memory space before setting up multicore computation.
Loaded: library(future), workers set to 6 (def),set Max mem size to 2GB (def)." )
Loaded: library(future), workers set to 6 (def),set Max mem size to 2GB (def).\n" )

gc(full = T)
try(memory.biggest.objects(), silent = T)
user_input <- readline(prompt="Are you sure that memory should not be cleaned before paralellizng? (y/n)")
user_input <- readline(prompt="\nDo you want to clean up memory before paralellizng (recommened)? (y/n)")

if (user_input == 'y') {
iprint("N. cores", cores)
library(future)
# plan("multiprocess", workers = cores)
plan("multisession", workers = cores)
if (user_input == 'n') {
iprint("\nN. cores:", cores)
# So to set Max mem size to 2GB, you would run :
options(future.globals.maxSize = maxMemSize)
} else { print("No parallelization")}

future::plan(strategy = strategy, workers = cores)
future::nbrOfWorkers()
} else { print("\nNo parallelization") }
}


Expand Down Expand Up @@ -3155,7 +3155,7 @@ multiFeaturePlot.A4 <- function(list.of.genes # Save multiple FeaturePlots, as j
, saveGeneList = FALSE
, w = wA4, h = hA4, scaling = 1
, format = c('jpg', 'pdf', 'png')[1]
, raster = TRUE # MarkdownHelpers::FALSE.unless('b.raster')
, raster = MarkdownHelpers::FALSE.unless('b.raster')
# , raster.dpi = c(512, 512)/4
, ...
# , jpeg.res = 225, jpeg.q = 90
Expand Down Expand Up @@ -3338,12 +3338,13 @@ plot.UMAP.tSNE.sidebyside <- function(obj = combined.obj, grouping = 'res.0.6',
PlotTopGenesPerCluster <- function(obj = combined.obj, cl_res = res, nrGenes = p$'n.markers'
, order.by = c("combined.score","avg_log2FC", "p_val_adj")[1]
, df_markers = obj@misc$"df.markers"[[paste0("res.",cl_res)]]
, raster = TRUE
, ...) {
topX.markers <- GetTopMarkers(df = df_markers, n= nrGenes
, order.by = order.by )
ls.topMarkers <- splitbyitsnames(topX.markers)
for (i in 1:length(ls.topMarkers)) {
multiFeaturePlot.A4(list.of.genes = ls.topMarkers[[i]], obj = obj, subdir = F
multiFeaturePlot.A4(list.of.genes = ls.topMarkers[[i]], obj = obj, subdir = F, raster = raster
, prefix = ppp("DEG.markers.res", cl_res, "cluster", names(ls.topMarkers)[i]), ...)
}
}
Expand Down Expand Up @@ -4310,7 +4311,7 @@ check.genes <- function(list.of.genes = ClassicMarkers, makeuppercase = FALSE, v
#' @export
fixZeroIndexing.seurat <- function(ColName.metadata = 'res.0.6', obj = org) { # Fix zero indexing in seurat clustering, to 1-based indexing
obj@meta.data[ ,ColName.metadata] = as.numeric(obj@meta.data[ ,ColName.metadata])+1
print(obj@meta.data[ ,ColName.metadata])
print(obj@meta.data[ , ColName.metadata])
return(obj)
}

Expand Down
5 changes: 0 additions & 5 deletions Seurat.utils.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix
Expand Down
9 changes: 9 additions & 0 deletions man/AutoLabelTop.logFC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PlotTopGenes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/PlotTopGenesPerCluster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/drop.levels.Seurat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/multiFeaturePlot.A4.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/parallel.computing.by.future.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 27 additions & 12 deletions man/write_metadata_to_tsv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2089f1b

Please sign in to comment.