Skip to content

Commit a38873b

Browse files
authored
Merge pull request #41 from pepkit/dev
v0.4.0
2 parents 345cb54 + 2e231a8 commit a38873b

30 files changed

Lines changed: 197 additions & 92 deletions

.github/workflows/new-build-R.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2+
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
name: R-CMD-check
12+
13+
jobs:
14+
R-CMD-check:
15+
runs-on: ${{ matrix.config.os }}
16+
17+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
config:
23+
- {os: windows-latest, r: 'release'}
24+
- {os: macOS-latest, r: 'release'}
25+
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
26+
27+
env:
28+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
29+
RSPM: ${{ matrix.config.rspm }}
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- uses: r-lib/actions/setup-r@master
35+
with:
36+
r-version: ${{ matrix.config.r }}
37+
38+
- uses: r-lib/actions/setup-pandoc@master
39+
40+
- name: Query dependencies
41+
run: |
42+
install.packages('remotes')
43+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
44+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
45+
shell: Rscript {0}
46+
47+
- name: Cache R packages
48+
if: runner.os != 'Windows'
49+
uses: actions/cache@v2
50+
with:
51+
path: ${{ env.R_LIBS_USER }}
52+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
53+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
54+
55+
- name: Install system dependencies
56+
if: runner.os == 'Linux'
57+
run: |
58+
while read -r cmd
59+
do
60+
eval sudo $cmd
61+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
62+
63+
- name: Install dependencies
64+
run: |
65+
remotes::install_cran("covr")
66+
remotes::install_deps(dependencies = TRUE)
67+
remotes::install_cran("rcmdcheck")
68+
shell: Rscript {0}
69+
70+
- name: Check
71+
env:
72+
_R_CHECK_CRAN_INCOMING_REMOTE_: false
73+
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
74+
shell: Rscript {0}
75+
76+
- name: Upload check results
77+
if: failure()
78+
uses: actions/upload-artifact@main
79+
with:
80+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
81+
path: check
82+
83+
- name: Report test coverage
84+
run: covr::codecov()
85+
shell: Rscript {0}

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: pepr
22
Type: Package
33
Title: Reading Portable Encapsulated Projects
4-
Version: 0.3.2
5-
Date: 2020-06-03
4+
Version: 0.4.0
5+
Date: 2020-10-15
66
Authors@R: c(person("Nathan", "Sheffield", email = "nathan@code.databio.org",
77
role = c("aut", "cph")),person("Michal","Stolarczyk",email="michal@virginia.edu",role=c("aut","cre")))
88
Maintainer: Michal Stolarczyk <michal@virginia.edu>

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# pepr 0.4.0 - 2020-10-14
2+
3+
## Changed
4+
5+
* added multiple subsample_table support
6+
7+
## Fixed
8+
9+
* issues with config file determination
10+
111
# pepr 0.3.2 - 2020-06-03
212

313
## Changed

R/config.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ setMethod(
6060
.expandList <- function(x) {
6161
if(is.list(x))
6262
return(lapply(x, .expandList))
63+
if(length(x) > 1)
64+
return(unname(sapply(x, .expandList)))
6365
return(suppressWarnings(.expandPath(x)))
6466
}
6567

@@ -129,12 +131,12 @@ setMethod("[[", "Config", function(x, i) {
129131

130132

131133
.DollarNames.Config <- function(x, pattern = "")
132-
grep(pattern, grep(names(x), value=TRUE))
134+
grep(paste0("^", pattern), grep(names(x), value=TRUE))
133135

134136
#' @rdname select-config
135137
#' @export
136138
setMethod("$", "Config", function(x, name){
137-
matches = grep(name, names(x))
139+
matches = grep(paste0("^", name), names(x))
138140
if(length(matches) == 0)
139141
return(NULL)
140142
hits = x[[matches]]

R/project.R

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ setMethod("initialize", "Project", function(.Object, ...) {
2525
# check if file path provided
2626
.Object@file = .makeAbsPath(ellipsis$file, parent = path.expand(getwd()))
2727
# instantiate config object and stick it in the config slot
28-
.Object@config = Config(ellipsis$file, ellipsis$amendments)
28+
.Object@config = Config(.Object@file, ellipsis$amendments)
2929
.Object = .loadSampleAnnotation(.Object)
3030
.Object = .modifySamples(.Object)
3131
}
@@ -479,40 +479,37 @@ setMethod(
479479
}
480480

481481

482-
#' Merge samples defined in sample table with ones in subsample table
482+
#' Load single subsample annotation
483483
#'
484484
#' @param .Object an object of \code{"\linkS4class{Project}"}
485+
#' @param path string, a path to the subsample table to read and incorporate
485486
#'
486487
#' @return an object of \code{"\linkS4class{Project}"}
487-
.mergeAttrs = function(.Object){
488-
cfg = config(.Object)
489-
if (!CFG_SUBSAMPLE_TABLE_KEY %in% names(cfg)) return(.Object)
490-
sampleSubannotationPath = cfg[[CFG_SUBSAMPLE_TABLE_KEY]]
491-
samples = sampleTable(.Object)
492-
samples = .listifyDF(samples)
493-
if (.safeFileExists(sampleSubannotationPath)) {
494-
samplesSubannotation = data.table::fread(sampleSubannotationPath)
488+
.loadSubsampleAnnotation = function(.Object, path) {
489+
if (.safeFileExists(path)) {
490+
samplesSubannotation = data.table::fread(path)
495491
} else{
496492
samplesSubannotation = data.table::data.table()
497493
}
498494
subNames = unique(samplesSubannotation$sample_name)
495+
samples = sampleTable(.Object)
496+
samples = .listifyDF(samples)
499497
rowNum = nrow(samples)
500498
# Creating a list to be populated in the loop and inserted
501499
# into the samples data.table as a column. This way the "cells"
502500
# in the samples table can consist of multiple elements
503-
colList = vector("list", rowNum)
504501
for (iName in subNames) {
505502
whichNames = which(samplesSubannotation$sample_name == iName)
506503
subTable = samplesSubannotation[whichNames,]
507504
dropCol = which(names(samplesSubannotation[whichNames,]) == "sample_name")
508505
subTable = subset(subTable, select = -dropCol)
506+
colList = vector("list", rowNum)
509507
for (iColumn in seq_len(ncol(subTable))) {
510508
colName = names(subset(subTable, select = iColumn))
511509
if (!any(names(samples) == colName)) {
512510
# The column doesn't exist, creating
513511
samples[, colName] = NULL
514512
} else{
515-
# colList=as.list(unname(samples[, ..colName]))[[1]]
516513
colList = samples[[colName]]
517514
}
518515
# The column exists
@@ -532,3 +529,20 @@ setMethod(
532529
.Object@samples = samples
533530
return(.Object)
534531
}
532+
533+
534+
535+
#' Merge samples defined in sample table with ones in subsample table(s)
536+
#'
537+
#' @param .Object an object of \code{"\linkS4class{Project}"}
538+
#'
539+
#' @return an object of \code{"\linkS4class{Project}"}
540+
.mergeAttrs = function(.Object){
541+
cfg = config(.Object)
542+
if (!CFG_SUBSAMPLE_TABLE_KEY %in% names(cfg)) return(.Object)
543+
sampleSubannotationPath = cfg[[CFG_SUBSAMPLE_TABLE_KEY]]
544+
for(p in sampleSubannotationPath){
545+
.Object = .loadSubsampleAnnotation(.Object, p)
546+
}
547+
return(.Object)
548+
}

R/utils.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,21 @@
126126
#' @export
127127
#' @return Target itself if already absolute, else target nested within parent.
128128
.makeAbsPath = function(perhapsRelative, parent) {
129-
if (!.isDefined(perhapsRelative)) return(perhapsRelative)
130-
perhapsRelative = .expandPath(perhapsRelative)
131-
if (.isAbsolute(perhapsRelative)) {
132-
abspath = perhapsRelative
133-
} else {
134-
abspath = file.path(path.expand(parent), perhapsRelative)
129+
res = c()
130+
for(pR in perhapsRelative){
131+
if (!.isDefined(pR)) return(pR)
132+
pR = .expandPath(pR)
133+
if (.isAbsolute(pR)) {
134+
abspath = pR
135+
} else {
136+
abspath = file.path(path.expand(parent), pR)
137+
}
138+
if (!.isAbsolute(abspath))
139+
stop("Relative path ", pR, " and parent ", parent ,
140+
" failed to create absolute path: ", abspath)
141+
res = append(res, abspath)
135142
}
136-
if (!.isAbsolute(abspath))
137-
stop("Relative path ", perhapsRelative, " and parent ", parent ,
138-
" failed to create absolute path: ", abspath)
139-
return(abspath)
143+
return(res)
140144
}
141145

142146
# Must test for is.null first, since is.na(NULL) returns a logical(0) which is

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/pepr)](http://cranlogs.r-pkg.org/badges/grand-total/pepr)
22
[![CRAN](http://www.r-pkg.org/badges/version-last-release/pepr)](http://www.r-pkg.org/badges/version-last-release/pepr)
3-
[![Build Status](https://travis-ci.org/pepkit/pepr.svg?branch=master)](https://travis-ci.org/pepkit/pepr)
4-
[![Coverage Status](https://coveralls.io/repos/github/pepkit/pepr/badge.svg?branch=dev)](https://coveralls.io/github/pepkit/pepr?branch=dev&service=github)
3+
![R-CMD-check](https://github.com/pepkit/pepr/workflows/R-CMD-check/badge.svg)
4+
[![codecov](https://codecov.io/gh/pepkit/pepr/branch/master/graph/badge.svg)](https://codecov.io/gh/pepkit/pepr)
55
[![PEP compatible](http://pepkit.github.io/img/PEP-compatible-green.svg)](http://pepkit.github.io)
66

77
# The `pepr` package: Portable Encapsulated Projects in R
@@ -25,7 +25,7 @@ Load a project and explore metadata like this:
2525
library("pepr")
2626
cfgPath = system.file(
2727
"extdata",
28-
paste0("example_peps-master"),
28+
"example_peps-master",
2929
"example_basic",
3030
"project_config.yaml",
3131
package = "pepr"

inst/extdata/example_peps-master/data/frog1_data.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

inst/extdata/example_peps-master/data/frog1a_data.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)