Skip to content

Commit

Permalink
- Edited the convertToRDS() function to allow the deletion of one or …
Browse files Browse the repository at this point in the history
…several channels in the dataset. The associated documentation was also edited as well

- Edited the version number
- Documented the argument of the checkNewVersion() function to meet the R package check
  • Loading branch information
PaulRegnier committed Dec 4, 2024
1 parent 38b4654 commit 3a4eb41
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PICAFlow
Title: PICAFlow: a complete R workflow dedicated to flow/mass cytometry data, from data pre-processing to deep and comprehensive analysis
Version: 1.0.5
Version: 1.0.6
Authors@R:
person("Paul", "Régnier", , "paul.regnier@aphp.fr", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9713-1132"))
Expand Down
36 changes: 28 additions & 8 deletions R/0_Preprocessing.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Check new version
#'
#' This function checks whether there is a new available version for `PICAFlow` in the GitHub repository. If this is the case, users are notified.
#' @param ... Useful to transfer other arguments to the function.
#'
#' @export

Expand Down Expand Up @@ -67,6 +68,8 @@ setupWorkingDirectory = function()
#'
#' Please note that the renaming both affects the parameters of each file AND the parameters in each self-contained compensation matrix.
#'
#' If needed, it is also possible to ask for the deletion of one or several channels in the dataset by specifying the word `DELETE` in the `to_desc` and `to_name` columns of the `conversionTable` table. In this case, it (or they) will simply be deleted from the samples which match with the associated pair of `from_desc` and `from_name` parameters used in the table.
#'
#' @return Generated `rds` files are saved to `rds` directory. The function also returns a matrix of all unique parameters (once correctly renamed) used in the dataset.
#'
#' @importFrom foreach %dopar%
Expand Down Expand Up @@ -143,6 +146,8 @@ convertToRDS = function(conversionTable = NULL)

}

parametersToRemoveID = NULL

foreach::foreach(b = 1:length(currentFileParameterDescriptions)) %do% {
currentDescriptionFrom = currentFileParameterDescriptions[b]
currentDescriptionName = currentFileParameterNames[b]
Expand All @@ -157,22 +162,37 @@ convertToRDS = function(conversionTable = NULL)

rowToReplaceID = as.numeric(which(currentFileParameterDescriptions == currentDescriptionFrom))

currentData@parameters@data[rowToReplaceID, "desc"] = paste(currentDescriptionTo, "_replaced", sep = "")
currentData@parameters@data[rowToReplaceID, "name"] = paste(currentNameTo, "_replaced", sep = "")
if(currentDescriptionTo == "DELETE" & currentNameTo == "DELETE")
{
parametersToRemoveID = c(parametersToRemoveID, rowToReplaceID)
# currentData = currentData[, -rowToReplaceID]
} else
{
currentData@parameters@data[rowToReplaceID, "desc"] = paste(currentDescriptionTo, "_replaced", sep = "")
currentData@parameters@data[rowToReplaceID, "name"] = paste(currentNameTo, "_replaced", sep = "")

colToReplaceID = as.numeric(which(colnames(currentData@exprs) == currentNameFrom))
colnames(currentData@exprs)[colToReplaceID] = paste(currentNameTo, "_replaced", sep = "")
colToReplaceID = as.numeric(which(colnames(currentData@exprs) == currentNameFrom))
colnames(currentData@exprs)[colToReplaceID] = paste(currentNameTo, "_replaced", sep = "")


if (length(compensationMatricesSlotName) > 0)
{
matchingCompensationNameID = which(colnames(currentData@description[compensationMatricesSlotName][[1]]) == currentNameFrom)
if (length(compensationMatricesSlotName) > 0)
{
matchingCompensationNameID = which(colnames(currentData@description[compensationMatricesSlotName][[1]]) == currentNameFrom)

colnames(currentData@description[compensationMatricesSlotName][[1]])[matchingCompensationNameID] = paste(currentNameTo, "_replaced", sep = "")
}

colnames(currentData@description[compensationMatricesSlotName][[1]])[matchingCompensationNameID] = paste(currentNameTo, "_replaced", sep = "")
}


}
}

if(is.null(parametersToRemoveID) == FALSE & length(parametersToRemoveID) > 0)
{
currentData = currentData[, -parametersToRemoveID]
}

currentData@parameters@data[, "desc"] = gsub("_replaced", "", currentData@parameters@data[, "desc"])
currentData@parameters@data[, "name"] = gsub("_replaced", "", currentData@parameters@data[, "name"])
colnames(currentData@exprs) = gsub("_replaced", "", colnames(currentData@exprs))
Expand Down
5 changes: 4 additions & 1 deletion man/checkNewVersion.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/convertToRDS.Rd

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

0 comments on commit 3a4eb41

Please sign in to comment.