Skip to content

Commit

Permalink
Merge pull request #7 from EmanuelSoda/fix
Browse files Browse the repository at this point in the history
another quick fix
  • Loading branch information
EmanuelSoda authored Sep 5, 2023
2 parents 92e60ce + ccf23dc commit fe36a9c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ScreenR
Type: Package
Title: Package to Perform High Throughput Biological Screening
Version: 0.99.54
Version: 0.99.55
Date: 2023-09-05
Authors@R: c(person("Emanuel Michele", "Soda", role = c("aut", "cre"),
email = "[email protected]",
Expand Down
32 changes: 22 additions & 10 deletions R/filter_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,44 @@
#' )
#'
filter_by_slope <- function(screenR_Object, genes, group_var_treatment,
group_var_control, slope_control, slope_treatment) {
group_var_control, slope_control = NULL, slope_treatment = NULL) {

# Compute the slope of the hits in the treatment Samples
slope_treatment <- ScreenR::compute_slope(screenR_Object, genes,
slope_trt <- ScreenR::compute_slope(screenR_Object, genes,
group_var = group_var_treatment
)


# Compute the slope of the hits in the control Samples
slope_DMSO <- ScreenR::compute_slope(screenR_Object, genes,
slope_contr <- ScreenR::compute_slope(screenR_Object, genes,
group_var = group_var_control
)

data <- screenR_Object@data_table

data <- dplyr::left_join(data, slope_treatment, by = "Gene")
data <- dplyr::left_join(data, slope_trt, by = "Gene")
data <- dplyr::rename(data, slope_treatment = .data$Slope)

data <- dplyr::left_join(data, slope_DMSO, by = "Gene")
data <- dplyr::left_join(data, slope_contr, by = "Gene")
data <- dplyr::rename(data, slope_control = .data$Slope)


data <- dplyr::filter(data, .data$slope_control >= slope_control)

data <- dplyr::filter(data, .data$slope_treatment <= slope_treatment)

if(!is.null(slope_control)){
print(unique(data$slope_control))
data <- dplyr::filter(data, abs(.data$slope_control) <=
abs(slope_control))
}

if(!is.null(slope_treatment)){
data <- dplyr::filter(data, abs(.data$slope_treatment) >=
abs(slope_treatment))
}

# The treatment has more effect than the control
data <- dplyr::filter(data, abs(.data$slope_control) <=
abs(.data$slope_treatment))

data <- dplyr::distinct(data, .data$Gene,
.data$slope_control, .data$slope_treatment)
return(data)
}

Expand Down
13 changes: 7 additions & 6 deletions tests/testthat/test-filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ test_that("filter_by_slope_fold", {
library(tibble)
object <- create_test_object()

data <- filter_by_slope(
data_p <- filter_by_slope(
screenR_Object = object,
genes = c("Gene_1", "Gene_300"),
genes = c("Gene_1", "Gene_2", "Gene_3", "Gene_4", "Gene_5",
"Gene_6", "Gene_7", "Gene_8", "Gene_9", "Gene_10",
"Gene_11", "Gene_12", "Gene_13", "Gene_14", "Gene_15"),
group_var_treatment = c("T1", "T2", "TRT"),
group_var_control = c("T1", "T2", "Time3", "Time4"),
slope_treatment = -0.5, slope_control = 0.5
)
expect_equal(class(data)[1], "tbl_df")
#data %>% dplyr::select(-c("Sequence", "Library", "Gene_ID"))
slope_treatment = NULL, slope_control = NULL
)
expect_true(all(abs(data_p$slope_treatment) > abs(data_p$slope_control)))
})


Expand Down

0 comments on commit fe36a9c

Please sign in to comment.