Skip to content

Commit

Permalink
v1.5.1 (#9)
Browse files Browse the repository at this point in the history
Bug fixes, performance improvements for mega datasets, explicit checking for OpenMP support.
Improved testing
  • Loading branch information
Sudaraka88 authored Jul 18, 2024
1 parent fc9e21f commit f841ba2
Show file tree
Hide file tree
Showing 19 changed files with 342 additions and 147 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
#- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
# http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand All @@ -47,7 +47,10 @@ jobs:
extra-packages: any::rcmdcheck
needs: check


- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'


5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@
*.o
.DS_Store
*.Rmd
Makevars

testscripts.R
testscript_op
tests
18 changes: 10 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: LDWeaver
Type: Package
Title: Genomewide Epistasis Analysis on Bacteria
Version: 1.5
Version: 1.5.1
Authors@R: person("Sudaraka", "Mallawaarachchi", email = "smallawaarachchi@gmail.com", role = c("aut", "cre"))
Maintainer: Sudaraka Mallawaarachchi <smallawaarachchi@gmail.com>
Description: Perform genomewide epistasis analysis by evaluating the LD structure in bacteria.
Expand All @@ -10,7 +10,7 @@ Encoding: UTF-8
LazyData: true
biocViews: Software
Depends: R (>= 4.0.0),
Imports:
Imports:
ape,
Biostrings,
chromoMap,
Expand Down Expand Up @@ -39,13 +39,15 @@ Imports:
utils,
VariantAnnotation
Suggests:
phytools,
ggtree,
ggnewscale,
spam,
spam64
phytools,
ggtree,
ggnewscale,
spam,
spam64,
testthat (>= 3.0.0)
LinkingTo: Rcpp, RcppArmadillo
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
URL: https://github.com/Sudaraka88/LDWeaver
BugReports: https://github.com/Sudaraka88/LDWeaver/issues
Biarch: TRUE
Config/testthat/edition: 3
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ importFrom(Matrix,rowSums)
importFrom(Matrix,sparseMatrix)
importFrom(Matrix,t)
importFrom(Matrix,which)
importFrom(MatrixExtra,crossprod)
importFrom(MatrixExtra,t)
importFrom(MatrixExtra,tcrossprod)
importFrom(RColorBrewer,brewer.pal)
importFrom(Rcpp,sourceCpp)
importFrom(RcppArmadillo,fastLm)
Expand Down Expand Up @@ -114,4 +111,7 @@ importFrom(utils,stack)
importFrom(utils,timestamp)
importFrom(utils,txtProgressBar)
importFrom(utils,write.table)
importMethodsFrom(MatrixExtra,crossprod)
importMethodsFrom(MatrixExtra,t)
importMethodsFrom(MatrixExtra,tcrossprod)
useDynLib(LDWeaver)
15 changes: 10 additions & 5 deletions R/BacGWES.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,24 @@
#' dset <- "full_dset"
#' gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
#' aln_path <- system.file("extdata", "sample.aln.gz", package = "LDWeaver")
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, gbk_path = gbk_path, validate_ref_ann_lengths = F)
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, gbk_path = gbk_path,
#' validate_ref_ann_lengths = F)
#'
#' # Example 2- using a SNP only alignment
#' dset <- "snp_dset"
#' gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
#' aln_path <- system.file("extdata", "snp_sample.fa.gz", package = "LDWeaver")
#' pos <- as.numeric(readLines(system.file("extdata", "snp_sample.fa.pos", package = "LDWeaver")))
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, aln_has_all_bases = F, pos = pos, gbk_path = gbk_path)
#' pos <- as.numeric(readLines(system.file("extdata", "snp_sample.fa.pos",
#' package = "LDWeaver")))
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, aln_has_all_bases = F,
#' pos = pos, gbk_path = gbk_path)
#'
# Example 3 - Redoing the full analysis as a mega scale dataset
#' dset <- "full_dset_spam"
#' gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
#' aln_path <- system.file("extdata", "sample.aln.gz", package = "LDWeaver")
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, gbk_path = gbk_path, validate_ref_ann_lengths = F, mega_dset = T)
#' LDWeaver::LDWeaver(dset = dset, aln_path = aln_path, gbk_path = gbk_path,
#' validate_ref_ann_lengths = F, mega_dset = T)
#' }
#' @export
LDWeaver = function(dset, aln_path, aln_has_all_bases = T, pos = NULL, gbk_path = NULL, gff3_path = NULL,
Expand Down Expand Up @@ -239,7 +243,8 @@ LDWeaver = function(dset, aln_path, aln_has_all_bases = T, pos = NULL, gbk_path
######## Welcome message ########
{
timestamp()
cat("\n ***** This is LDWeaver", as.character(packageVersion(pkg = "LDWeaver")), " *****")
cat("\n ***** This is LDWeaver", as.character(packageVersion(pkg = "LDWeaver")), " *****\n")
test_openmp()
if(ncores > 1) cat(paste("\n\n Performing GWES analysis on:", dset, " - using", ncores, "cores\n\n"))
if(ncores == 1) cat(paste("\n\n Performing GWES analysis on:", dset, "\n\n"))
if(perform_SR_analysis_only) cat("Only short-range analysis requested. \n")
Expand Down
5 changes: 3 additions & 2 deletions R/LDSummaryPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Function to generate the bird's-eye view of the genomewide LD structure (measured as weighted-MI)
#'
#' @importFrom MatrixExtra crossprod
#' @importMethodsFrom MatrixExtra crossprod
#' @importFrom Matrix sparseMatrix t
#' @importFrom grDevices colorRampPalette png
#' @importFrom heatmap3 heatmap3
Expand Down Expand Up @@ -97,7 +97,8 @@ genomewide_LDMap = function(lr_links_path, sr_links_path, plot_save_path, reduce
cat(paste("Reducing dimensionality from", length(pos_vec) ,"x", length(pos_vec), "-> "))
x = .mat(length(pos_vec), reducer)
cat(paste(ncol(x) ,"x", ncol(x), "...\n"))
reduced_mat = MatrixExtra::crossprod(x, MatrixExtra::crossprod(sprs, x))
# reduced_mat = MatrixExtra::crossprod(x, MatrixExtra::crossprod(sprs, x))
reduced_mat = crossprod(x, crossprod(sprs, x))
htm = as(reduced_mat, 'matrix')/reducer^2
nms = as.character(pos_vec[seq(from = 1, to = length(pos_vec), by = reducer-1)])
colnames(htm) = rownames(htm) = nms[1:nrow(htm)]
Expand Down
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
.Call('_LDWeaver_extractRef', PACKAGE = 'LDWeaver', file)
}

test_openmp <- function() {
invisible(.Call('_LDWeaver_test_openmp', PACKAGE = 'LDWeaver'))
}

.readFasta <- function(file, pos_len) {
.Call('_LDWeaver_readFasta', PACKAGE = 'LDWeaver', file, pos_len)
}
Expand Down
Loading

0 comments on commit f841ba2

Please sign in to comment.