Skip to content

Instantly share code, notes, and snippets.

@mgaynor1
Created December 2, 2024 19:08
Show Gist options
  • Select an option

  • Save mgaynor1/a12584cbe8b722c93e746a513b4c5968 to your computer and use it in GitHub Desktop.

Select an option

Save mgaynor1/a12584cbe8b722c93e746a513b4c5968 to your computer and use it in GitHub Desktop.
AlternativeFunction-nQuack
process_data_chrom <- function(file, min.depth = 2, max.depth.quantile.prob = 0.9,
error = 0.01, trunc = c(0,0), chrom){
df <- data.table::fread(file, sep = "\t")
if(ncol(df) != 7){
message("Did you run `prepare_data()` on this file? Your data is in the wrong format, please correct and try again.")
} else{
df <- df[which(df$chr == chrom), 3:7]
df <- stats::na.omit(df)
dfm <- as.matrix(df)
allelefreq <- process_rcpp(dfm, min.depth, max.depth.quantile.prob, trunc, error )
return(allelefreq)
}
}
@mgaynor1

mgaynor1 commented Dec 2, 2024 •

Copy link
Copy Markdown
Author
process_data_chroms <- function(file, min.depth = 2, max.depth.quantile.prob = 0.9,
                               error = 0.01, trunc = c(0,0), chroms){
  df <- data.table::fread(file, sep = "\t")
  if(ncol(df) != 7){
    message("Did you run `prepare_data()` on this file? Your data is in the wrong format, please correct and try again.")
  } else{
    df <- df[which(df$chr %in% chroms), 3:7]
    df <- stats::na.omit(df)
    dfm <- as.matrix(df)
    
    allelefreq <- process_rcpp(dfm, min.depth, max.depth.quantile.prob, trunc, error )
    return(allelefreq)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment