Skip to content

Commit

Permalink
rename package
Browse files Browse the repository at this point in the history
  • Loading branch information
kalidouBA committed Nov 21, 2023
1 parent d795608 commit 7dd2647
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 40 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: SSDRnaSeq
Title: Semi-Supervise cellular deconvolution of Bulk RnaSeq using NMF and CiberSortx, DCQ or others
Package: DICEPRO
Title: Deconvolution with Iterative Completion for Estimating cellular Proportion from RNA-seq data
Version: 0.0.0.1
Authors@R: c(person("Kalidou", "BA", role = c("aut","cre"),
email = "kalidou.ba@u-bordeaux.fr"),
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,SSDRnaSeq)
export(SSDRnaSeq)
S3method(plot,DICEPRO)
export(DICEPRO)
export(computPerf)
export(generateProp)
export(generate_ref_matrix)
Expand Down
15 changes: 4 additions & 11 deletions R/SSDRnaSeq.R → R/DICEPRO.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@
#'
#' @examples
#' if(interactive()){
#'
#' simulation <- simulation(loi = "gauss", scenario = " ", bias = TRUE,
#' nSample = 10, prop = NULL, nGenes = 50, nCellsType = 5)
#' cellTypeOut <- sample(1:ncol(simulation$reference), 2)
#' refDataIncomplet <- simulation$reference[,-cellTypeOut]
#' results <- SSDRnaSeq(reference = refDataIncomplet, bulk = simulation$bulk,
#' results <- DICEPRO(reference = refDataIncomplet, bulk = simulation$bulk,
#' nIteration = 5, methodDeconv = "DCQ")
#' print(results)
#' }

SSDRnaSeq <- function(reference, bulk, nIteration = 50, methodDeconv = "CSx", metric = "RRMSE",
DICEPRO <- function(reference, bulk, nIteration = 50, methodDeconv = "CSx", metric = "RRMSE",
cibersortx_email = NULL, cibersortx_token = NULL) {

stopifnot(methodDeconv %in% c("CSx", "DCQ", "CDSeq", "DeconRNASeq", "FARDEEP", "BayesPrism"))
Expand All @@ -78,26 +77,22 @@ SSDRnaSeq <- function(reference, bulk, nIteration = 50, methodDeconv = "CSx", me
if(length(methodDeconv) > 1)
methodDeconv <- methodDeconv[1]


cellTypeName <- colnames(reference)
geneIntersect <- intersect(rownames(reference), rownames(bulk))

reference <- apply(reference[geneIntersect, ], 2, as.numeric)
bulk <- apply(bulk[geneIntersect, ], 2, as.numeric)
rownames(reference) <- rownames(bulk) <- geneIntersect


# Initialize variables to store results and metrics
matrixAbundances <- performs <- performs2plot <- opt <- NULL

for (iterate_ in 0:nIteration) {
message("Current iteration ++++++++++++++++++++++++++++++++ ", iterate_)

out_Dec <- running_method(bulk, reference, methodDeconv, cibersortx_email, cibersortx_token)

bulkDeconv <- as.matrix(reference) %*% out_Dec


matrixAbundances <- rbind(matrixAbundances, cbind.data.frame(t(out_Dec)[,cellTypeName], "Iterate" = iterate_))

if(iterate_ > 0){
Expand All @@ -112,7 +107,6 @@ SSDRnaSeq <- function(reference, bulk, nIteration = 50, methodDeconv = "CSx", me
(metric == "RRMSE" && performs[iterate_-1] - performs[iterate_] < 0 ))) {
opt <- ifelse(iterate_ == nIteration, iterate_, iterate_ - 1)
message("Convergence criteria Done with optimal criteria: ", opt, "\nBreaking the loop.")

break
}
}
Expand All @@ -125,14 +119,13 @@ SSDRnaSeq <- function(reference, bulk, nIteration = 50, methodDeconv = "CSx", me
colnames(unknownMat) <- paste0("Unknown_", col, "_", iterate_)
reference <- cbind(reference, unknownMat)
}

}

rownames(performs2plot) <- NULL

results <- list("Prediction" = out_Dec, "Matrix_prediction" = matrixAbundances,
"New_signature" = reference, "Optimal_iteration" = opt,
"performs2plot" = performs2plot)

class(results) <- "SSDRnaSeq"
class(results) <- "DICEPRO"
return(results)
}
4 changes: 2 additions & 2 deletions R/plot.SSDRnaSeq.R → R/plot.DICEPRO.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#'
#' @return A combined plot showing the cell abundance heatmap and error plot.
#'
#'@method plot SSDRnaSeq
#'@method plot DICEPRO
#'@import patchwork
#'
#' @seealso Functions for generating individual plots: \code{\link{heatmap_abundances}}, \code{\link{metric_plot}}.
#'
#' @export

plot.SSDRnaSeq <- function(x, ...){
plot.DICEPRO <- function(x, ...){

if(length(unique(x$Matrix_prediction$Iterate)) > 1){
# Combine the heatmap and error between folds
Expand Down
11 changes: 5 additions & 6 deletions man/SSDRnaSeq.Rd → man/DICEPRO.Rd

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

8 changes: 4 additions & 4 deletions man/plot.SSDRnaSeq.Rd → man/plot.DICEPRO.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(SSDRnaSeq)
library(DICEPRO)

test_check("SSDRnaSeq")
test_check("DICEPRO")
4 changes: 2 additions & 2 deletions tests/testthat/test_SSDRnaSeq.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_that("SSDRnaSeq", {
test_that("DICEPRO", {
skip_on_cran()
library(clusterGeneration)
library(NMF)
Expand All @@ -13,6 +13,6 @@ test_that("SSDRnaSeq", {
cellTypeOut <- sample(1:ncol(simulation$reference), 1)
refDataIncomplet <- simulation$reference[,-cellTypeOut]

# res <- SSDRnaSeq(reference = refDataIncomplet, bulk = simulation$bulk, nIteration = 2,
# res <- DICEPRO(reference = refDataIncomplet, bulk = simulation$bulk, nIteration = 2,
# methodDeconv = "DCQ")
})
14 changes: 7 additions & 7 deletions vignettes/test_real_datasets.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(


```{r setup}
library(SSDRnaSeq)
library(DICEPRO)
library(ADAPTS)
library(NMF)
```
Expand All @@ -30,20 +30,20 @@ library(NMF)
#
#
# ```{r}
# bulk <- SSDRnaSeq::GSE107011$gene_expression
# res <- SSDRnaSeq::SSDRnaSeq(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# bulk <- DICEPRO::GSE107011$gene_expression
# res <- DICEPRO::DICEPRO(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# ```
#
#
#
# ```{r}
# bulk <- SSDRnaSeq::GSE107572$gene_expression
# res <- SSDRnaSeq::SSDRnaSeq(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# bulk <- DICEPRO::GSE107572$gene_expression
# res <- DICEPRO::DICEPRO(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# ```
#
#
# ```{r}
# bulk <- SSDRnaSeq::GSE127813$gene_expression
# res <- SSDRnaSeq::SSDRnaSeq(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# bulk <- DICEPRO::GSE127813$gene_expression
# res <- DICEPRO::DICEPRO(reference = LM22, bulk = bulk, nIteration = 2, methodDeconv = "DCQ")
# ```

4 changes: 2 additions & 2 deletions vignettes/test_simulation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(


```{r setup}
library(SSDRnaSeq)
library(DICEPRO)
library(ADAPTS)
library(NMF)
```
Expand Down Expand Up @@ -94,7 +94,7 @@ names(cellTypeOut) <- paste0(as.character(percs * 100), "%")
#
# for (i in names(cellTypeOut)) {
# refDataIncomplet <- reference[,-cellTypeOut[[i]]]
# listAllResult[[i]] <- SSDRnaSeq(reference = refDataIncomplet,
# listAllResult[[i]] <- DICEPRO(reference = refDataIncomplet,
# bulk = simulation$bulk,
# nIteration = nIteration,
# methodDeconv = "DCQ",
Expand Down

0 comments on commit 7dd2647

Please sign in to comment.