diff --git a/DESCRIPTION b/DESCRIPTION index abff9ae..6a5edfa 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sigurd Type: Package Title: Single cell Genotyping Using RNA Data -Version: 0.3.4 +Version: 0.3.6 Authors@R: c( person(given = "Martin", family = "Grasshoff", diff --git a/NAMESPACE b/NAMESPACE index cb6356c..d8e3dbb 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,8 +8,10 @@ export(CalculateConsensus) export(CalculateCorrelationPValue) export(CalculateCoverage) export(CalculateFisherTestPValue) +export(CalculateForwardReads) export(CalculateQuality) export(CalculateRefReads) +export(CalculateReverseReads) export(CalculateStrandCorrelation) export(CallSupport) export(ClonalDefinition) @@ -21,6 +23,7 @@ export(GetCellInfoPerVariant) export(GetVariantInfo) export(HeatmapVoi) export(LoadingMAEGATK_typewise) +export(LoadingMGATK_typewise) export(LoadingRawMatrix_typewise) export(LoadingVCF_typewise) export(LoadingVarTrix_typewise) @@ -38,6 +41,7 @@ export(VariantQuantileThresholding_Combined) export(VariantSelection_Group) export(VariantSelection_Quantile) export(VariantSelection_TopCells) +export(VariantSelection_VMR) export(VariantWiseCorrelation) export(VariantWiseFisherTest) export(char_to_numeric) @@ -70,6 +74,7 @@ importFrom(Matrix,rowSums) importFrom(Matrix,sparseMatrix) importFrom(Matrix,summary) importFrom(Matrix,t) +importFrom(MatrixGenerics,rowVars) importFrom(S4Vectors,DataFrame) importFrom(S4Vectors,merge) importFrom(S4Vectors,metadata) diff --git a/R/RowWiseSplit.R b/R/RowWiseSplit.R index 35940d4..05466b2 100755 --- a/R/RowWiseSplit.R +++ b/R/RowWiseSplit.R @@ -3,15 +3,19 @@ #'Performing the correlation or Fisher test association for a SummarizedExperiment object requires extreme amounts of memory. #'To reduce the amount of memory necessary, we instead get the individual rows from the consensus assay. #'We can then remove the NoCalls (no reads) from the individual vectors, further reducing the amount of memory needed. +#' +#'When the NoCalls are removed, the repective cells are also removed if a different assay is selected. #'@importFrom parallel mclapply #'@importFrom SummarizedExperiment assays #'@param se SummarizedExperiment object. #'@param n_cores Number of cores to use. #'@param remove_nocalls Do you want to remove NoCall cells? +#'@param assay_to_split Which assay to you want to split? #'@export -RowWiseSplit <- function(se, n_cores = 1, minimum_reads, remove_nocalls = TRUE){ - consensus <- SummarizedExperiment::assays(se)$consensus - consensus_list <- parallel::mclapply(rownames(se), SeparatingMatrixToList, total_matrix = consensus, remove_nocalls = remove_nocalls, mc.cores = n_cores) +RowWiseSplit <- function(se, n_cores = 1, assay_to_split = "consensus", remove_nocalls = TRUE){ + selected_assay <- SummarizedExperiment::assays(se)[[assay_to_split]] + consensus <- SummarizedExperiment::assays(se)[["consensus"]] + consensus_list <- parallel::mclapply(rownames(se), SeparatingMatrixToList, total_matrix = selected_assay, assay_to_split = assay_to_split, consensus = consensus, remove_nocalls = remove_nocalls, mc.cores = n_cores) names(consensus_list) <- rownames(se) return(consensus_list) } diff --git a/R/SeparatingMatrixToList.R b/R/SeparatingMatrixToList.R index 3bb7ff1..d88071b 100755 --- a/R/SeparatingMatrixToList.R +++ b/R/SeparatingMatrixToList.R @@ -7,20 +7,27 @@ #'@importFrom stats na.omit #'@param row_use The row the separate. #'@param total_matrix The matrix to be split. +#'@param assay_to_split Which assay are we splitting? #'@param remove_nocalls Do you want to remove NoCall cells? #'@export -SeparatingMatrixToList <- function(row_use, total_matrix, remove_nocalls = TRUE){ +SeparatingMatrixToList <- function(row_use, total_matrix, consensus, assay_to_split = "consensus", remove_nocalls = TRUE){ selected_row <- total_matrix[row_use,] selected_row <- stats::na.omit(selected_row) if(remove_nocalls == TRUE){ # We remove the NoCall cells. - selected_row <- selected_row[selected_row != 0] - selected_row[selected_row == 1] <- 0 - selected_row[selected_row >= 2] <- 1 + selected_consensus <- consensus[row_use,] + selected_consensus <- stats::na.omit(selected_consensus) + selected_row <- selected_row[selected_consensus != 0] + if(assay_to_split == "consensus"){ + selected_row[selected_row == 1] <- 0 + selected_row[selected_row >= 2] <- 1 + } } else if(remove_nocalls == FALSE){ - selected_row[selected_row <= 1] <- 0 - selected_row[selected_row >= 2] <- 1 + if(assay_to_split == "consensus"){ + selected_row[selected_row <= 1] <- 0 + selected_row[selected_row >= 2] <- 1 + } } return(selected_row) } diff --git a/README.md b/README.md index 019df68..d0d36ae 100755 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The mutation data was obtained from the Sanger Institute Catalogue Of Somatic Mu ``` -# Current Features v0.3.4 +# Current Features v0.3.6 - Loading data from VarTrix and MAEGATK. - Transforming the data to be compatible for joint analysis. diff --git a/man/RowWiseSplit.Rd b/man/RowWiseSplit.Rd index 9c7ac2b..eb48885 100755 --- a/man/RowWiseSplit.Rd +++ b/man/RowWiseSplit.Rd @@ -4,17 +4,26 @@ \alias{RowWiseSplit} \title{RowWiseSplit} \usage{ -RowWiseSplit(se, n_cores = 1, minimum_reads, remove_nocalls = TRUE) +RowWiseSplit( + se, + n_cores = 1, + assay_to_split = "consensus", + remove_nocalls = TRUE +) } \arguments{ \item{se}{SummarizedExperiment object.} \item{n_cores}{Number of cores to use.} +\item{assay_to_split}{Which assay to you want to split?} + \item{remove_nocalls}{Do you want to remove NoCall cells?} } \description{ Performing the correlation or Fisher test association for a SummarizedExperiment object requires extreme amounts of memory. To reduce the amount of memory necessary, we instead get the individual rows from the consensus assay. We can then remove the NoCalls (no reads) from the individual vectors, further reducing the amount of memory needed. + +When the NoCalls are removed, the repective cells are also removed if a different assay is selected. } diff --git a/man/SeparatingMatrixToList.Rd b/man/SeparatingMatrixToList.Rd index 544ba7f..751c67f 100755 --- a/man/SeparatingMatrixToList.Rd +++ b/man/SeparatingMatrixToList.Rd @@ -4,13 +4,21 @@ \alias{SeparatingMatrixToList} \title{SeparatingMatrixToList} \usage{ -SeparatingMatrixToList(row_use, total_matrix, remove_nocalls = TRUE) +SeparatingMatrixToList( + row_use, + total_matrix, + consensus, + assay_to_split = "consensus", + remove_nocalls = TRUE +) } \arguments{ \item{row_use}{The row the separate.} \item{total_matrix}{The matrix to be split.} +\item{assay_to_split}{Which assay are we splitting?} + \item{remove_nocalls}{Do you want to remove NoCall cells?} } \description{ diff --git a/tests/testthat/test-SeparatingMatrixToList.R b/tests/testthat/test-SeparatingMatrixToList.R index 8d49ffd..7dc7cc7 100755 --- a/tests/testthat/test-SeparatingMatrixToList.R +++ b/tests/testthat/test-SeparatingMatrixToList.R @@ -5,10 +5,10 @@ test_that("Testing SeparatingMatrixToList.R", { test2 <- sigurd::SeparatingMatrixToList("chrM_2_A_G", input_matrix, remove_nocalls = FALSE) test3 <- sigurd::SeparatingMatrixToList("chrM_2_A_T", input_matrix, remove_nocalls = FALSE) test4 <- sigurd::SeparatingMatrixToList("chrM_4_C_G", input_matrix, remove_nocalls = FALSE) - test1_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_1_G_A", input_matrix, remove_nocalls = TRUE) - test2_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_2_A_G", input_matrix, remove_nocalls = TRUE) - test3_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_2_A_T", input_matrix, remove_nocalls = TRUE) - test4_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_4_C_G", input_matrix, remove_nocalls = TRUE) + test1_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_1_G_A", input_matrix, consensus = input_matrix, remove_nocalls = TRUE) + test2_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_2_A_G", input_matrix, consensus = input_matrix, remove_nocalls = TRUE) + test3_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_2_A_T", input_matrix, consensus = input_matrix, remove_nocalls = TRUE) + test4_removed_nocalls <- sigurd::SeparatingMatrixToList("chrM_4_C_G", input_matrix, consensus = input_matrix, remove_nocalls = TRUE) # We generate the expected outputs. expected_result1 <- c(Cell_1 = 0, Cell_2 = 1, Cell_3 = 1, Cell_4 = 0) expected_result2 <- c(Cell_1 = 0, Cell_2 = 1, Cell_3 = 1, Cell_4 = 0)