Skip to content
Merged
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
42 changes: 21 additions & 21 deletions R/buildComponent.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}

if (mz_method %in% c("merging") && mz_twins == TRUE && !is.null(mz_row_pairs) && length(mz_row_pairs) > 0 &&
config$component %in% c("additive")) {
config$component %in% c("additive")) {
# replace all MZ twin IDs with the first twin's ID in each pair so they are merged for the path tracing and all subsequent steps. We will copy the values back to the second twin at the end.
ped <- fuseTwins(ped = ped, mz_row_pairs = mz_row_pairs, mz_id_pairs = mz_id_pairs, config = config, beta = beta)
if (config$verbose == TRUE) {
Expand Down Expand Up @@ -233,8 +233,8 @@


if (config$resume == TRUE && file.exists(checkpoint_files$r_checkpoint) &&
file.exists(checkpoint_files$gen_checkpoint) &&
file.exists(checkpoint_files$gen_checkpoint) &&
file.exists(checkpoint_files$mtSum_checkpoint) &&

Check notice on line 237 in R/buildComponent.R

View check run for this annotation

codefactor.io / CodeFactor

R/buildComponent.R#L237

Indentation should be 6 spaces but is 4 spaces. (indentation_linter)
file.exists(checkpoint_files$newIsPar_checkpoint) &&
file.exists(checkpoint_files$count_checkpoint)
) {
Expand Down Expand Up @@ -341,7 +341,7 @@
# --- Step 4: T crossproduct ---

if (config$resume == TRUE && file.exists(checkpoint_files$tcrossprod_checkpoint) &&
config$component != "generation") {
config$component != "generation") {
if (config$verbose == TRUE) message("Resuming: Loading tcrossprod...\n")
r <- readRDS(checkpoint_files$tcrossprod_checkpoint)
} else {
Expand Down Expand Up @@ -428,7 +428,7 @@
if (config$saveable == TRUE) {
saveRDS(r, file = checkpoint_files$final_matrix, compress = config$compress)
}
return(r)
r
}

#' Take a pedigree and turn it into an additive genetics relatedness matrix
Expand Down Expand Up @@ -647,19 +647,19 @@
}
)

return(result)
result
}

#' Initialize checkpoint files
#' @inheritParams ped2com
#' @keywords internal

initializeCheckpoint <- function(config = list(
verbose = FALSE,
saveable = FALSE,
resume = FALSE,
save_path = "checkpoint/"
)) {
verbose = FALSE,
saveable = FALSE,
resume = FALSE,
save_path = "checkpoint/"
)) {
# Define checkpoint files
# Ensure save path exists
if (config$saveable == TRUE && !dir.exists(config$save_path)) {
Expand Down Expand Up @@ -693,7 +693,7 @@
final_matrix = file.path(config$save_path, "final_matrix.rds")
)

return(checkpoint_files)
checkpoint_files
}

#' Assign parent values based on component type
Expand All @@ -703,12 +703,12 @@
if (component %in% c("generation", "additive")) {
parVal <- .5
} else if (component %in%
c("common nuclear", "mitochondrial", "mtdna", "mitochondria")) {
c("common nuclear", "mitochondrial", "mtdna", "mitochondria")) {
parVal <- 1
} else {
stop("Don't know how to set parental value")
}
return(parVal)
parVal
}

#' Load or compute a checkpoint
Expand All @@ -726,12 +726,12 @@
compress = TRUE) {
if (config$resume == TRUE && file.exists(file)) {
if (config$verbose == TRUE && !is.null(message_resume)) cat(message_resume)
return(readRDS(file))
readRDS(file)
} else {
if (config$verbose == TRUE && !is.null(message_compute)) cat(message_compute)
result <- compute_fn()
if (config$saveable == TRUE) saveRDS(result, file = file, compress = compress)
return(result)
result
}
}

Expand Down Expand Up @@ -763,7 +763,7 @@
compress = compress
)

return(isPar)
isPar
}

#' Load or compute the isChild matrix
Expand All @@ -783,7 +783,7 @@
compress = compress
)

return(isChild)
isChild
}

#' Load or compute the inverse diagonal matrix
Expand Down Expand Up @@ -812,7 +812,7 @@
rm(r, isChild)
gc()
}
return(r2)
r2
}


Expand All @@ -834,8 +834,8 @@
parList = NULL, lens = NULL,
compress = TRUE) {
if (config$resume == TRUE &&
file.exists(checkpoint_files$parList) &&
file.exists(checkpoint_files$parList) &&
file.exists(checkpoint_files$lens)) {

Check notice on line 838 in R/buildComponent.R

View check run for this annotation

codefactor.io / CodeFactor

R/buildComponent.R#L838

Indentation should be 8 spaces but is 4 spaces. (indentation_linter)
if (config$verbose == TRUE) {
message("Resuming: Loading parent-child adjacency data...\n")
}
Expand All @@ -857,8 +857,8 @@
}

if (config$resume == TRUE &&
file.exists(checkpoint_files$iss) &&
file.exists(checkpoint_files$iss) &&
file.exists(checkpoint_files$jss)) { # fix to check actual

Check notice on line 861 in R/buildComponent.R

View check run for this annotation

codefactor.io / CodeFactor

R/buildComponent.R#L861

Indentation should be 8 spaces but is 4 spaces. (indentation_linter)
if (config$verbose == TRUE) message("Resuming: Constructed matrix...\n")
jss <- readRDS(checkpoint_files$jss)
iss <- readRDS(checkpoint_files$iss)
Expand Down Expand Up @@ -894,5 +894,5 @@
saveRDS(list_of_adjacencies$iss, file = checkpoint_files$iss, compress = compress)
}
}
return(list_of_adjacencies)
list_of_adjacencies
}
Loading