Closed explodecomputer closed 5 years ago
@explodecomputer the sections {args, counts}
are not present in the harmonised.bcf example that I have (MRC-IEU-research/projects/IEU2/P4/013/working/data/bcfs/harmonised.bcf) -- is there a newer version of this example file?
These headers are not present in the files from @elswob as well.
Thanks @YiLiu6240
I will discuss with Matt how to ensure that we have the same headers through the two different systems. But in the meantime perhaps you could generate like this instead
header_to_json <- function(filename)
{
tf <- tempfile()
cmd <- paste0("bcftools view -h ", filename, " | grep -E '^##' | cut -d '#' -f 3 > ", tf)
system(cmd)
a <- scan(tf, what=character(), sep="\n")
x1 <- regmatches(a, regexpr("=", a), invert = TRUE) %>% do.call("rbind", .)
x2 <- as.list(x1[,2])
names(x2) <- x1[,1]
x2 <- as.data.frame(x2, stringsAsFactors=FALSE)
x2 <- lapply(x2, function(x)
{
o <- as.numeric(x)
ifelse(is.na(o), x, o)
}) %>% as.data.frame %>% unbox
x2 %>% toJSON
write_json(o, path=gsub("bcf$", "json", filename))
}
I'm not sure if the report module is dependent on any specific parameters but if there is anything then do let me know!
In the current version we extract header from the bcf file to a json which is then read by rmarkdown (and can be used by other aggregation scripts).
Suggested example script to do this (e.g. called
header_to_json.r
:To run:
This creates harmonised.json (overwrites, beware). Output:
Requires the bcftools binary on the PATH.