Skip to content

Commit 7e903b0

Browse files
committed
Further simplify examples and tests related to lawremi/rtracklayer#83
1 parent aaa0947 commit 7e903b0

File tree

5 files changed

+59
-56
lines changed

5 files changed

+59
-56
lines changed

R/coverage_matrix.R

+8-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@
5555
#' @examples
5656
#'
5757
#' if (.Platform$OS.type != "windows") {
58+
#' ## Workaround for https://github.com/lawremi/rtracklayer/issues/83
59+
#' download_study("SRP002001", type = "mean")
60+
#' download_study("SRP002001", type = "samples")
61+
#'
5862
#' ## Reading BigWig files is not supported by rtracklayer on Windows
5963
#' ## Define expressed regions for study DRP002835, chrY
60-
#' regions <- expressed_regions("DRP002835", "chrY",
64+
#' regions <- expressed_regions("SRP002001", "chrY",
6165
#' cutoff = 5L,
62-
#' maxClusterGap = 3000L
66+
#' maxClusterGap = 3000L,
67+
#' outdir = "SRP002001"
6368
#' )
6469
#'
6570
#' ## Now calculate the coverage matrix for this study
66-
#' rse <- coverage_matrix("DRP002835", "chrY", regions)
71+
#' rse <- coverage_matrix("SRP002001", "chrY", regions, outdir = "SRP002001")
6772
#'
6873
#' ## One row per region
6974
#' identical(length(regions), nrow(rse))

R/expressed_regions.R

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,21 @@
3737
#' [railMatrix][derfinder::railMatrix]
3838
#'
3939
#' @examples
40-
#' ## Define expressed regions for study SRP009615, chrY
40+
#' ## Define expressed regions for study DRP002835, chrY
4141
#' if (.Platform$OS.type != "windows") {
42+
#' ## Workaround for https://github.com/lawremi/rtracklayer/issues/83
43+
#' download_study("SRP002001", type = "mean")
44+
#'
4245
#' ## Reading BigWig files is not supported by rtracklayer on Windows
43-
#' regions <- expressed_regions("SRP009615", "chrY",
46+
#' regions <- expressed_regions("SRP002001", "chrY",
4447
#' cutoff = 5L,
45-
#' maxClusterGap = 3000L
48+
#' maxClusterGap = 3000L,
49+
#' outdir = "SRP002001"
4650
#' )
4751
#' }
4852
#' \dontrun{
4953
#' ## Define the regions for multiple chrs
50-
#' regs <- sapply(chrs, expressed_regions, project = "SRP009615", cutoff = 5L)
54+
#' regs <- sapply(chrs, expressed_regions, project = "SRP002001", cutoff = 5L)
5155
#'
5256
#' ## You can then combine them into a single GRanges object if you want to
5357
#' library("GenomicRanges")

man/coverage_matrix.Rd

+8-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/expressed_regions.Rd

+8-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-data.R

+27-42
Original file line numberDiff line numberDiff line change
@@ -109,53 +109,38 @@ test_that("Scaling", {
109109
})
110110

111111
if (.Platform$OS.type != "windows") {
112-
range <-
113-
GRanges(seqnames = "chrY", ranges = IRanges(1, 57227415))
114-
output <-
115-
tryCatch(
116-
rtracklayer::import(
117-
"http://duffel.rail.bio/recount/SRP002001/bw/mean_SRP002001.bw",
118-
selection = reduce(range),
119-
as = "RleList"
120-
),
121-
error = identity
112+
regions <- expressed_regions("SRP002001", "chrY", cutoff = 5, outdir = tmpdir)
113+
## Artificially remove the mean coverage file so that the file will have to
114+
## get downloaded on the first test, then it'll be present for the second
115+
## test
116+
unlink(localfiles["mean_SRP002001.bw"])
117+
118+
test_that("Expressed regions", {
119+
expect_equal(
120+
regions,
121+
expressed_regions("SRP002001", "chrY", cutoff = 5, outdir = tmpdir)
122122
)
123-
if (inherits(output, "error")) {
124-
warning("Remote BigWig file access is failing. See https://github.com/lawremi/rtracklayer/issues/83 for more details.")
125-
} else {
126-
regions <- expressed_regions("SRP002001", "chrY", cutoff = 5)
127-
## Artificially remove the mean coverage file so that the file will have to
128-
## get downloaded on the first test, then it'll be present for the second
129-
## test
130-
unlink(localfiles["mean_SRP002001.bw"])
131-
132-
test_that("Expressed regions", {
133-
expect_equal(
134-
regions,
135-
expressed_regions("SRP002001", "chrY", cutoff = 5, outdir = tmpdir)
136-
)
137-
})
123+
})
138124

139125

140-
rse_ER <- coverage_matrix("SRP002001", "chrY", regions)
141-
## Same for the phenotype data and the sample bigwig file
142-
unlink(localfiles["SRP002001.tsv"])
143-
unlink(localfiles["SRR036661.bw"])
126+
rse_ER <- coverage_matrix("SRP002001", "chrY", regions, outdir = tmpdir)
127+
## Same for the phenotype data and the sample bigwig file
128+
unlink(localfiles["SRP002001.tsv"])
129+
unlink(localfiles["SRR036661.bw"])
144130

145-
test_that("Coverage matrix", {
146-
expect_equal(
147-
rse_ER,
148-
coverage_matrix("SRP002001", "chrY", regions, outdir = tmpdir)
149-
)
150-
expect_equal(
151-
rse_ER,
152-
coverage_matrix("SRP002001", "chrY", regions,
153-
outdir = tmpdir,
154-
chunksize = 500
155-
)
131+
test_that("Coverage matrix", {
132+
expect_equal(
133+
rse_ER,
134+
coverage_matrix("SRP002001", "chrY", regions, outdir = tmpdir)
135+
)
136+
expect_equal(
137+
rse_ER,
138+
coverage_matrix("SRP002001", "chrY", regions,
139+
outdir = tmpdir,
140+
chunksize = 500
156141
)
157-
})
158-
}
142+
)
143+
})
159144
}
160145

161146
## Check size once:

0 commit comments

Comments
 (0)