Skip to content

Commit bc26ce5

Browse files
committed
update tests and dependencies bugs
1 parent 2719de4 commit bc26ce5

File tree

8 files changed

+106
-29
lines changed

8 files changed

+106
-29
lines changed

NAMESPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,31 @@ export(format_input)
66
export(ppc_seq)
77
import(Rcpp)
88
import(dplyr)
9+
import(ggplot2)
910
import(methods)
1011
import(rstan)
1112
import(tidybayes)
13+
importFrom(dplyr,enquo)
1214
importFrom(foreach,"%do%")
1315
importFrom(foreach,foreach)
1416
importFrom(magrittr,"%$%")
1517
importFrom(magrittr,divide_by)
1618
importFrom(magrittr,multiply_by)
1719
importFrom(magrittr,set_rownames)
20+
importFrom(purrr,as_mapper)
21+
importFrom(purrr,map)
1822
importFrom(purrr,map2)
1923
importFrom(purrr,map_int)
24+
importFrom(purrr,pmap)
2025
importFrom(rstan,sampling)
2126
importFrom(rstan,vb)
2227
importFrom(tibble,as_tibble)
28+
importFrom(tibble,rowid_to_column)
2329
importFrom(tibble,tibble)
30+
importFrom(tidyr,drop_na)
2431
importFrom(tidyr,gather)
32+
importFrom(tidyr,nest)
33+
importFrom(tidyr,separate)
2534
importFrom(tidyr,spread)
2635
importFrom(ttBulk,add_normalised_counts_bulk)
2736
useDynLib(ppcSeq, .registration = TRUE)

R/ppcSeq.R

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ add_attr = function(var, attribute, name){
1212
#' This is a generalisation of ifelse that acceots an object and return an objects
1313
#'
1414
#' @import dplyr
15+
#' @importFrom purrr as_mapper
1516
#'
1617
#' @param .x A tibble
1718
#' @param .p A boolean
@@ -230,6 +231,10 @@ find_optimal_number_of_chains = function(how_many_posterior_draws,
230231

231232
#' Identify the optimal number of chain
232233
#' based on how many draws we need from the posterior
234+
#'
235+
#' @importFrom tibble rowid_to_column
236+
#' @importFrom purrr map
237+
#'
233238
#' @param counts_MPI A matrix of read count information
234239
#' @param to_exclude A vector of oulier data points to exclude
235240
#' @param shards An integer
@@ -297,6 +302,10 @@ inits_fx =
297302

298303
#' Produce generated quantities plots with marked uotliers
299304
#'
305+
#' @importFrom purrr pmap
306+
#' @importFrom purrr map_int
307+
#' @import ggplot2
308+
#'
300309
#' @param .x A tibble
301310
#' @param value_column A symbol object
302311
#' @param sample_column A symbol object
@@ -394,6 +403,9 @@ add_deleterious_if_covariate_exists = function(input.df, X){
394403
)
395404
}
396405

406+
#' merge_results
407+
#'
408+
#' @importFrom tidyr nest
397409
merge_results = function(res_discovery, res_test, formula, gene_column, value_column, sample_column, do_check_only_on_detrimental){
398410

399411
res_discovery %>%
@@ -463,9 +475,10 @@ merge_results = function(res_discovery, res_test, formula, gene_column, value_co
463475
)
464476
}
465477

466-
# Select only significant genes plus background for efficient normalisation
467-
# Input: tibble
468-
# Ouyput: tibble
478+
#' Select only significant genes plus background for efficient normalisation
479+
#'
480+
#' @importFrom rstan sampling
481+
#' @importFrom rstan vb
469482
select_to_check_and_house_keeping = function(input.df, do_check_column, significance_column, gene_column, how_many_negative_controls){
470483
input.df %>%
471484
{
@@ -530,11 +543,13 @@ run_model = function(model, full_bayes, chains, how_many_posterior_draws, inits_
530543
)
531544
}
532545

546+
#' add_exposure_rate
547+
#'
548+
#' @importFrom tidyr separate
533549
add_exposure_rate = function(input.df, fit){
534550

535551
writeLines(sprintf("executing %s", "add_exposure_rate"))
536552

537-
538553
input.df %>%
539554
left_join(
540555
fit %>%
@@ -568,6 +583,11 @@ check_if_within_posterior = function(input.df, my_df, do_check_column, value_col
568583
ungroup
569584
}
570585

586+
#' parse_fit
587+
#'
588+
#' @importFrom tidyr separate
589+
#' @importFrom tidyr nest
590+
#'
571591
parse_fit = function(fit, adj_prob_theshold){
572592

573593
writeLines(sprintf("executing %s", "parse_fit"))
@@ -624,6 +644,11 @@ check_columns_exist = function(input.df, sample_column, gene_column, value_colum
624644
)
625645
}
626646

647+
648+
#' Check if NA
649+
#'
650+
#' @importFrom tidyr drop_na
651+
#' @importFrom dplyr enquo
627652
check_if_any_NA = function(input.df, sample_column, gene_column, value_column, significance_column, do_check_column, formula_columns){
628653

629654
# Prepare column same enquo

man/add_exposure_rate.Rd

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_if_any_NA.Rd

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/merge_results.Rd

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/parse_fit.Rd

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/select_to_check_and_house_keeping.Rd

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-ppcSeq.R

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
11
context('ppcSeq')
22

3-
test_that("dummy",expect_equal(1,1))
3+
test_that("Quick test",{
44

5-
#
6-
#
7-
# test_that("Quick test",{
8-
#
95
FDR_threshold = 0.01
106

117
res =
12-
ppcSeq::counts %>%
13-
mutate(is_significant = FDR < FDR_threshold) %>%
148
ppc_seq(
9+
dplyr::mutate(ppcSeq::counts, is_significant = FDR < FDR_threshold),
1510
formula = ~ Label,
1611
significance_column = PValue,
1712
do_check_column = is_significant,
1813
value_column = value,
1914
percent_false_positive_genes = "5%", tol_rel_obj = 0.01
2015
)
21-
#
22-
# expect_equal(
23-
#
24-
# length(
25-
# attr(
26-
# create_ttBulk(
27-
# ttBulk::counts_mini,
28-
# sample_column = sample,
29-
# transcript_column = transcript,
30-
# counts_column = `read count`
31-
# ) ,
32-
# "parameters"
33-
# )
34-
# ),
35-
# 3
36-
# )
37-
#
38-
# })
16+
17+
expect_equal(
18+
19+
as.integer(unlist(res[c(1, 2, 4, 5, 6),5])),
20+
c(0,1,0,0,0)
21+
)
22+
23+
})

0 commit comments

Comments
 (0)