Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy object conversion #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions convert-legacy-rdata.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env Rscript
suppressPackageStartupMessages({
library(argparse)
})

args = commandArgs(TRUE)
if (length(args) == 0) {
message('Run convert-legacy-rdata.R --help for list of input arguments.')
quit()
}

parser = ArgumentParser(description = 'Convert .Rdata file from older versions of facets-suite to the new .rds format.')
parser$add_argument('-i', '--input-file', required = TRUE,
help = 'Input file')
parser$add_argument('-o', '--output-prefix', required = FALSE,
help = 'Name of output file [default input basename]')
args = parser$parse_args()

output = ifelse(is.null(args$output_prefix),
paste0(gsub('.Rdata', '', basename(args$input_file)), '.rds'),
paste0(args$output_prefix, '.rds'))

# Convert input to new format -------------------------------------------------------------------------------------

load(args$input_file)

new_format = list(
snps = out$jointseg,
segs = fit$cncf,
purity = fit$purity,
ploidy = fit$ploidy,
diplogr = fit$dipLogR,
alballogr = out$alBalLogR,
flags = out$flags,
em_flags = fit$emflags,
loglik = fit$loglik
)

saveRDS(new_format, output)