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

Merge daphne-dev #15

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b990cf6
testthat folder
bbitarello Jun 22, 2023
fcd3fcb
testing work
daphnehanse11 Jun 23, 2023
b7a50cd
Update ncd1.R
bbitarello Jun 27, 2023
30a8aee
testing 123
daphnehanse11 Jun 28, 2023
4c007d2
simplify ncd1
bbitarello Jul 3, 2023
d99e788
pending daphne check
bbitarello Jul 3, 2023
8a989f3
Major update
bbitarello Jul 6, 2023
51c264f
Merge pull request #4 from bitarellolab/bbita-dev
bbitarello Jul 6, 2023
c47cbc8
Update vcf_ncd1.R
daphnehanse11 Jul 7, 2023
d8ecf0a
Merge branch 'master' into DaphneDev
daphnehanse11 Jul 7, 2023
01b92c0
readme
bbitarello Jul 7, 2023
43c56a3
testing
daphnehanse11 Jul 10, 2023
99ded0f
more global variables
daphnehanse11 Jul 11, 2023
38bb0af
even more tests
daphnehanse11 Jul 17, 2023
a084019
tests for ncd1
daphnehanse11 Jul 18, 2023
2d3bdc5
readme
bbitarello Jul 19, 2023
681b2ac
many updates
bbitarello Jul 20, 2023
e711f12
Update ncd1.R
bbitarello Jul 20, 2023
918f55d
Merge branch 'bbita-dev' into DaphneDev
daphnehanse11 Jul 20, 2023
a374f3c
Merge pull request #6 from bitarellolab/DaphneDev
daphnehanse11 Jul 20, 2023
1668067
changes to ncd1
bbitarello Jul 20, 2023
e5e97ce
Update ncd1.R
bbitarello Jul 20, 2023
03ca0e3
.
bbitarello Jul 20, 2023
802a998
more changes to ncd1 and some to ncd2
bbitarello Jul 21, 2023
6e047de
Merge pull request #7 from bitarellolab/bbita-dev
daphnehanse11 Jul 21, 2023
e6b3377
test changes
daphnehanse11 Jul 21, 2023
e12a170
commented out
daphnehanse11 Jul 21, 2023
0f62b85
updates and bug fixes
daphnehanse11 Jul 24, 2023
3590cad
test for ncd1
daphnehanse11 Jul 25, 2023
079573c
Update ncd2.R
bbitarello Jul 25, 2023
fa550fa
Merge pull request #8 from bitarellolab/bbita-dev
daphnehanse11 Jul 25, 2023
4937d0e
man updates
daphnehanse11 Jul 26, 2023
dc52a51
updates
daphnehanse11 Sep 18, 2023
0a673f2
trying to update read_vcf
daphnehanse11 Sep 25, 2023
714c0c8
it works now!
daphnehanse11 Sep 29, 2023
16d1ae5
pos.range
daphnehanse11 Sep 29, 2023
638487d
Update modified_read_vcf.R
daphnehanse11 Oct 4, 2023
0cf4db1
oush
daphnehanse11 Oct 4, 2023
0dbcd89
FINALLY
daphnehanse11 Nov 5, 2023
6decd6c
notes
daphnehanse11 Nov 6, 2023
5d91fc2
functions
daphnehanse11 Nov 13, 2023
fcf959a
made the lil markdown file
daphnehanse11 Feb 18, 2024
f8eb5fb
bal
daphnehanse11 Feb 23, 2024
f0aa0d1
install code
daphnehanse11 Feb 26, 2024
9f2ee2a
Update renv.lock
daphnehanse11 Feb 29, 2024
2e9aab0
tutorial
bbitarello Mar 1, 2024
5d5dac2
Merge branch 'master' of https://github.com/bitarellolab/balselr into…
bbitarello Mar 4, 2024
e721000
Merge pull request #10 from bitarellolab/DaphneDev
bbitarello Mar 4, 2024
051d4df
Create r.yml
bbitarello Mar 4, 2024
3c0a2d7
cleanup2
bbitarello Mar 4, 2024
89e0182
Delete xaringan-themer.css
bbitarello Mar 4, 2024
711e3ed
renv
bbitarello Mar 4, 2024
addb3e1
fix warning about 'user nobody'
bbitarello Mar 4, 2024
458e51e
Merge pull request #11 from bitarellolab/bbitarello-patch-1
bbitarello Mar 18, 2024
7c69308
Update NAMESPACE
bbitarello Apr 18, 2024
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
2 changes: 2 additions & 0 deletions .Renviron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RENV_CONFIG_WATCHDOG_ENABLED = FALSE
R_BUILD_TAR=tar
40 changes: 40 additions & 0 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
#
# See https://github.com/r-lib/actions/tree/master/examples#readme for
# additional example workflows available for the R community.

name: R

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
r-version: ['3.6.3', '4.1.1']

steps:
- uses: actions/checkout@v3
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a
with:
r-version: ${{ matrix.r-version }}
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
.Rdata
.httr-oauth
.DS_Store
local_only/
inst/doc
15 changes: 9 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ Description: Produce input files for different balancing selection programs/test
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
LazyData: true
Imports:
assertthat,
data.table,
dplyr,
glue,
magrittr,
reticulate,
slendr,
stringr,
testthat,
tictoc
stringr
Depends:
R (>= 2.10)
Suggests:
knitr,
rmarkdown,
testthat (>= 3.1.9),
withr
Config/testthat/edition: 3
VignetteBuilder: knitr
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(hello)
export(modmod_read_vcf)
export(ncd1)
export(ncd2)
export(outfile_path)
Expand Down
25 changes: 13 additions & 12 deletions R/count_alleles.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#' Count derived or ancestral alleles for a given vcf position
#' @param x A vector containing 0s and 1s corresponding to allele states
#' @param der Return derived. Logical. If TRUE, returns the counts of
#' derived (alternate)
#' alleles. If FALSE, returns ancestral (ref) counts
#' @param x A vector containing 0s and 1s corresponding to allele states. 0/0: homozygous reference; 0/1: heterozygous; 1/1: homozygous alternate

#' @param split Pattern to look for. Inherited from stringr::str_split
#' @param index 1 or 2 or c(1,2). Which alleles to consider.
#' @examples data.table::data.table(col1="1|1", col2="1|0", col3="0|0") %>%
#' dplyr::summarise(across(col1:col3, .count_alleles))
.count_alleles<-function(x, split="|",index=c(1,2), der = F){
x<-.split_geno(x = x, split = split, index = index)
if(der == T){sum(x, na.rm=T)}else if (der == F){sum(!is.na(x))-sum(x, na.rm=T)}


.count_alleles<-function(x, split="|"){
x<-.split_geno(x = x, split = split)
#if(der == T){sum(x, na.rm=T)}else if (der == F){sum(!is.na(x))-sum(x, na.rm=T)}
#sum(!is.na(x))-sum(x, na.rm=T)
#ref<-sum(x==0, na.rm=T) #number of ref alleles
sum(x==1, na.rm=T) #number of alt alleles

}
.count_nonmissing<-function(x, split="|",index=c(1,2)){
x<-.split_geno(x = x, split = split, index = index)
.count_nonmissing<-function(x, split="|"){
x<-.split_geno(x = x, split = split)
sum(!is.na(x))
}
18 changes: 0 additions & 18 deletions R/hello.R

This file was deleted.

39 changes: 39 additions & 0 deletions R/modified_read_vcf.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#' Read vcf
#'
#' @param x The path and name of a vcf file
#' @return Returns a data.table object containing only SNPs
#' @export
#'
#' @examples read_vcf(x=system.file(package="balselr", "example.vcf"))
#' @import data.table
#' @importFrom data.table ":="
#'
modmod_read_vcf <- function(x = "inst/example.vcf", pos.range = NULL, id.range = NULL) {
inp <- data.table::fread(x, skip = "##", header = TRUE)
data.table::setnames(inp, "#CHROM", "CHR")

inp <- inp[REF %in% c("A", "C", "T", "G") & ALT %in% c("A", "C", "T", "G")]

if (!is.null(pos.range)) {
if (length(pos.range) == 2) {
inp <- inp[POS >= pos.range[1] & POS <= pos.range[2]]
} else {
inp <- inp[POS %in% pos.range]
}
}

col.range <- 1:9

if (!is.null(id.range)) {
if (length(id.range) == 2) {
col.range <- c(col.range, (10 + id.range[1] - 1):(10 + id.range[2] - 1))
} else {
col.range <- c(col.range, 9 + id.range)
}
col.range <- col.range[col.range <= ncol(inp)]
}

inp <- inp[, .SD, .SDcols = col.range]

return(inp)
}
Loading
Loading