Skip to content

Commit

Permalink
Pass normalization arguments from DownloadAndAppendNimble to AppendNi…
Browse files Browse the repository at this point in the history
…mbleCounts
  • Loading branch information
bbimber committed Jan 4, 2024
1 parent e11de0a commit 8ae8f28
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions R/NimbleAPI.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ utils::globalVariables(
#' @param dropAmbiguousFeatures If true, any ambiguous feature (identified as containing a comma)
#' @param reuseExistingDownloads If true, any pre-existing downloaded nimble TSVs will be re-used
#' @param performDietSeurat If true, DietSeurat will be run, which removes existing reductions. This may or may not be required based on your usage, but the default is true out of caution.
#' @param normalizeData Passed directly to AppendNimbleCounts()
#' @param assayForLibrarySize Passed directly to AppendNimbleCounts()
#' @param maxLibrarySizeRatio Passed directly to AppendNimbleCounts()
#' @return A modified Seurat object.
#' @export
DownloadAndAppendNimble <- function(seuratObject, targetAssayName, outPath=tempdir(), enforceUniqueFeatureNames=TRUE, allowableGenomes=NULL, ensureSamplesShareAllGenomes = TRUE, dropAmbiguousFeatures = TRUE, reuseExistingDownloads = FALSE, performDietSeurat = TRUE) {
DownloadAndAppendNimble <- function(seuratObject, targetAssayName, outPath=tempdir(), enforceUniqueFeatureNames=TRUE, allowableGenomes=NULL, ensureSamplesShareAllGenomes = TRUE, dropAmbiguousFeatures = TRUE, reuseExistingDownloads = FALSE, performDietSeurat = TRUE, normalizeData = TRUE, assayForLibrarySize = 'RNA', maxLibrarySizeRatio = 0.05) {
# Ensure we have a DatasetId column
if (is.null(seuratObject@meta.data[['DatasetId']])) {
stop('Seurat object lacks DatasetId column')
Expand Down Expand Up @@ -92,7 +95,7 @@ DownloadAndAppendNimble <- function(seuratObject, targetAssayName, outPath=tempd
write.table(df, outFile, sep="\t", col.names=F, row.names=F, quote=F)

print(paste0('Appending counts to ', targetAssayName))
seuratObject <- AppendNimbleCounts(seuratObject=seuratObject, targetAssayName = targetAssayName, nimbleFile=outFile, dropAmbiguousFeatures = dropAmbiguousFeatures, performDietSeurat = FALSE)
seuratObject <- AppendNimbleCounts(seuratObject=seuratObject, targetAssayName = targetAssayName, nimbleFile=outFile, dropAmbiguousFeatures = dropAmbiguousFeatures, performDietSeurat = FALSE, normalizeData = normalizeData, assayForLibrarySize = assayForLibrarySize, maxLibrarySizeRatio = maxLibrarySizeRatio)
unlink(outFile)

return(seuratObject)
Expand Down
2 changes: 1 addition & 1 deletion R/NimbleAppend.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' @param maxLibrarySizeRatio If normalizeData is true, then this is passed to CellMembrane::LogNormalizeUsingAlternateAssay
#' @return A modified Seurat object.
#' @export
AppendNimbleCounts <- function(seuratObject, nimbleFile, targetAssayName, dropAmbiguousFeatures = TRUE, renameConflictingFeatures = TRUE, duplicateFeatureSuffix = ".Nimble", normalizeData = TRUE, performDietSeurat = TRUE, assayForLibrarySize = 'RNA', maxLibrarySizeRatio = 0.01) {
AppendNimbleCounts <- function(seuratObject, nimbleFile, targetAssayName, dropAmbiguousFeatures = TRUE, renameConflictingFeatures = TRUE, duplicateFeatureSuffix = ".Nimble", normalizeData = TRUE, performDietSeurat = TRUE, assayForLibrarySize = 'RNA', maxLibrarySizeRatio = 0.05) {
if (!file.exists(nimbleFile)) {
stop(paste0("Nimble file not found: ", nimbleFile))
}
Expand Down
2 changes: 1 addition & 1 deletion man/AppendNimbleCounts.Rd

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

11 changes: 10 additions & 1 deletion man/DownloadAndAppendNimble.Rd

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

0 comments on commit 8ae8f28

Please sign in to comment.