Export andromeda generated by computePathways object to sharable csv-files and/or a zip archive.
export(
andromeda,
outputPath,
ageWindow = 10,
minCellCount = 5,
censorType = "minCellCount",
archiveName = NULL
)
(Andromeda::andromeda()
)
Andromeda object.
(character(1)
)
(integer(n)
: 10
)
Number of years to bin age groups into. It may also be a vector of integers.
I.e. c(0, 18, 150)
which will results in age group 0-18
which includes
subjects < 19
. And age group 18-150
which includes subjects > 18
.
(integer(1)
: 5
)
Minimum count required per pathway. Censors data below x
as <x
. This
minimum value will carry over to the sankey diagram and sunburst plot.
(character(1)
)
"minCellCount"
Censors pathways <minCellCount
to minCellCount
.
"remove"
Censors pathways <minCellCount
by removing them completely.
"mean"
Censors pathways <minCellCount
to the mean of all frequencies below minCellCount
(character(1)
: NULL
)
If not NULL
adds the exported files to a ZIP-file with the specified archive name.
(invisible(NULL)
)
# \donttest{
library(TreatmentPatterns)
library(CDMConnector)
library(dplyr)
if (require("CirceR", character.only = TRUE, quietly = TRUE)) {
withr::local_envvar(
R_USER_CACHE_DIR = tempfile(),
EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile())
)
downloadEunomiaData(overwrite = TRUE)
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main")
cohortSet <- readCohortSet(
path = system.file(package = "TreatmentPatterns", "exampleCohorts")
)
cdm <- generateCohortSet(
cdm = cdm,
cohortSet = cohortSet,
name = "cohort_table"
)
cohorts <- cohortSet %>%
# Remove 'cohort' and 'json' columns
select(-"cohort", -"json") %>%
mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>%
rename(
cohortId = "cohort_definition_id",
cohortName = "cohort_name",
) %>%
select("cohortId", "cohortName", "type")
outputEnv <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm
)
export(
andromeda = outputEnv,
outputPath = tempdir()
)
Andromeda::close(outputEnv)
DBI::dbDisconnect(con, shutdown = TRUE)
}
#>
#> Download completed!
#> ℹ Generating 8 cohorts
#> ℹ Generating cohort (1/8) - acetaminophen
#> ✔ Generating cohort (1/8) - acetaminophen [124ms]
#>
#> ℹ Generating cohort (2/8) - amoxicillin
#> ✔ Generating cohort (2/8) - amoxicillin [103ms]
#>
#> ℹ Generating cohort (3/8) - aspirin
#> ✔ Generating cohort (3/8) - aspirin [121ms]
#>
#> ℹ Generating cohort (4/8) - clavulanate
#> ✔ Generating cohort (4/8) - clavulanate [103ms]
#>
#> ℹ Generating cohort (5/8) - death
#> ✔ Generating cohort (5/8) - death [51ms]
#>
#> ℹ Generating cohort (6/8) - doxylamine
#> ✔ Generating cohort (6/8) - doxylamine [100ms]
#>
#> ℹ Generating cohort (7/8) - penicillinv
#> ✔ Generating cohort (7/8) - penicillinv [101ms]
#>
#> ℹ Generating cohort (8/8) - viralsinusitis
#> ✔ Generating cohort (8/8) - viralsinusitis [163ms]
#>
#> Construct treatment pathways, this may take a while for larger datasets.
#> Original number of rows: 8352
#> After eraCollapseSize: 0
#> Selected 1544
#> out of 8352 rows
#> Iteration: 1
#> Switches: 8352
#> FRFS Combinations: 4
#> LRFS Combinations: 1527
#> Selected 4
#> out of 559 rows
#> Iteration: 2
#> Switches: 559
#> FRFS Combinations: 0
#> LRFS Combinations: 4
#> After combinationWindow: 555
#> Time needed to execute combination window 0.0618213653564453
#> Order the combinations.
#> After filterTreatments: 554
#> Adding drug sequence number.
#> After maxPathLength: 554
#> Adding concept names.
#> Ordering the combinations.
#> constructPathways done.
#> Writing metadata to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/metadata.csv
#> Writing treatmentPathways to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/treatmentPathways.csv
#> Censoring 1224 pathways with a frequency <5 to 5.
#> Writing summaryStatsTherapyDuration to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/summaryStatsTherapyDuration.csv
#> Writing countsYearPath to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/countsYear.csv
#> Writing countsAgePath to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/countsAge.csv
#> Writing countsSexPath to C:\Users\MVANKE~1\AppData\Local\Temp\Rtmp0eZMoy/countsSex.csv
# }