Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/testthat/test-datasets.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
library(testthat)

test_that("read_afq_sarica loads the sarica dataset", {
df_sarica <- read_afq_sarica()
df_sarica <- tractable::read_afq_sarica()

expect_equal(nrow(df_sarica), 96000)
expect_equal(ncol(df_sarica), 8)
expect_equal(length(unique(df_sarica$subjectID)), 48)
})

test_that("read_afq_weston_havens loads the WH dataset", {
df_hbn <- read_afq_weston_havens()
df_hbn <- tractable::read_afq_weston_havens()

expect_equal(nrow(df_hbn), 154000)
expect_equal(ncol(df_hbn), 8)
Expand All @@ -24,7 +26,7 @@ test_that("read_afq_hbn loads the HBN dataset", {

test_that("read_afq_files returns an unsupervised dataset when pheno_csv is NULL", {
nodes_url <- "https://github.com/yeatmanlab/Sarica_2017/raw/gh-pages/data/nodes.csv"
df <- read_afq_files(nodes_csv = nodes_url,
df <- tractable::read_afq_files(nodes_csv = nodes_url,
dwi_metrics = c("fa", "md"),
pheno_cols = c("age", "class", "gender"))

Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-fit-models.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
test_that("fit_gam runs as expected", {
library(testthat)

sarica <- read_afq_sarica()
testthat::test_that("fit_gam runs as expected", {

sarica <- tractable::read_afq_sarica()
sarica$group <- factor(sarica$class)
sarica$subjectID <- unclass(factor(sarica$subjectID))

selected <- select_bundle(
selected <- tractable::select_bundle(
df_afq = sarica,
tract = "Right Corticospinal",
dwi_metric = "fa",
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-gam.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
library(testthat)

test_that("tractable_single_bundle runs as expected", {
sarica <- read_afq_sarica()
sarica <- tractable::read_afq_sarica()
sarica$group <- factor(sarica$class)
sarica$subjectID <- unclass(factor(sarica$subjectID))
gam_fit <- expect_no_error(
tractable_single_bundle(df_afq = sarica,
tractable::tractable_single_bundle(df_afq = sarica,
tract = "Right Corticospinal",
participant_id = "subjectID",
group_by = "group",
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-select.r
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
library(testthat)

test_that("select_bundle runs as expected", {
sarica <- read_afq_sarica()
sarica <- tractable::read_afq_sarica()
sarica$group <- factor(sarica$class)
sarica$subjectID <- unclass(factor(sarica$subjectID))

selected <- expect_no_error(
select_bundle(df_afq = sarica,
tractable::select_bundle(df_afq = sarica,
tract = "Right Corticospinal",
dwi_metric = "fa",
covariates = c("age", "group"),
Expand All @@ -19,7 +21,7 @@ expect_identical(tract_names, c("Right Corticospinal"))
expect_identical(length(colnames(df_tract)), as.integer(6))

selected <- expect_no_error(
select_bundle(df_afq = sarica,
tractable::select_bundle(df_afq = sarica,
tract = "all",
dwi_metric = "fa",
covariates = c("age", "group"),
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-shuffle.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library(testthat)

test_that("shuffle_df shuffles an afq dataframe", {
df_afq <- read.csv("afq_12_rows.csv")

Expand Down
Loading