-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into nf-core-template-merge-2.14.1
- Loading branch information
Showing
40 changed files
with
1,787 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ template: | |
prefix: nf-core | ||
skip: | ||
- igenomes | ||
lint: | ||
files_exist: | ||
- conf/igenomes.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
args = commandArgs(trailingOnly=TRUE) | ||
|
||
|
||
if (length(args) < 3) { | ||
stop("\nthis program needs at least 3 inputs\n1: output filename\n2-*: input files", call.=FALSE) | ||
} | ||
|
||
fout <- args[1] | ||
finp <- args[2:length(args)] | ||
nf <- length(finp) | ||
|
||
require(raster) | ||
|
||
|
||
img <- brick(finp[1]) | ||
nc <- ncell(img) | ||
nb <- nbands(img) | ||
|
||
|
||
sum <- matrix(0, nc, nb) | ||
num <- matrix(0, nc, nb) | ||
|
||
for (i in 1:nf){ | ||
|
||
data <- brick(finp[i])[] | ||
|
||
num <- num + !is.na(data) | ||
|
||
data[is.na(data)] <- 0 | ||
sum <- sum + data | ||
|
||
} | ||
|
||
mean <- sum/num | ||
img[] <- mean | ||
|
||
|
||
writeRaster(img, filename = fout, format = "GTiff", datatype = "INT2S", | ||
options = c("INTERLEAVE=BAND", "COMPRESS=LZW", "PREDICTOR=2", | ||
"NUM_THREADS=ALL_CPUS", "BIGTIFF=YES", | ||
sprintf("BLOCKXSIZE=%s", img@file@blockcols[1]), | ||
sprintf("BLOCKYSIZE=%s", img@file@blockrows[1]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
args = commandArgs(trailingOnly=TRUE) | ||
|
||
|
||
if (length(args) < 3) { | ||
stop("\nthis program needs at least 3 inputs\n1: output filename\n2-*: input files", call.=FALSE) | ||
} | ||
|
||
fout <- args[1] | ||
finp <- args[2:length(args)] | ||
nf <- length(finp) | ||
|
||
require(raster) | ||
|
||
|
||
img <- raster(finp[1]) | ||
nc <- ncell(img) | ||
|
||
|
||
last <- rep(1, nc) | ||
|
||
for (i in 1:nf){ | ||
|
||
data <- raster(finp[i])[] | ||
|
||
last[!is.na(data)] <- data[!is.na(data)] | ||
|
||
} | ||
|
||
img[] <- last | ||
|
||
|
||
writeRaster(img, filename = fout, format = "GTiff", datatype = "INT2S", | ||
options = c("INTERLEAVE=BAND", "COMPRESS=LZW", "PREDICTOR=2", | ||
"NUM_THREADS=ALL_CPUS", "BIGTIFF=YES", | ||
sprintf("BLOCKXSIZE=%s", img@file@blockcols[1]), | ||
sprintf("BLOCKYSIZE=%s", img@file@blockrows[1]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
args = commandArgs(trailingOnly=TRUE) | ||
|
||
|
||
if (length(args) != 7) { | ||
stop("\ngive input directory (mosaic) as 1st arg\ngive reference rasters (*.tif) as 2nd-7th args in order: | ||
woody cover change, woody cover year of change, | ||
herbaceous cover change, herbaceous cover year of change, | ||
peak change, peak year of change, ", call.=FALSE) | ||
} | ||
|
||
dinp <- args[1] | ||
|
||
# load package | ||
require(terra) | ||
|
||
|
||
|
||
# LOAD REFERENCE | ||
####################################################################### | ||
woody_cover_changes_ref <- rast(args[2]) | ||
woody_cover_year_of_change_ref <- rast(args[3]) | ||
|
||
herbaceous_cover_changes_ref <- rast(args[4]) | ||
herbaceous_cover_year_of_change_ref <- rast(args[5]) | ||
|
||
peak_changes_ref <- rast(args[6]) | ||
peak_year_of_change_ref <- rast(args[7]) | ||
|
||
|
||
# WOODY COVER CHANGE (VALUE OF BASE LEVEL) | ||
####################################################################### | ||
|
||
fname <- dir(dinp, ".*HL_TSA_LNDLG_SMA_VBL-CAO.vrt$", full.names=TRUE) | ||
|
||
woody_cover_rast <- rast(fname) | ||
|
||
woody_cover_changes <- woody_cover_rast$CHANGE | ||
woody_cover_year_of_change <- woody_cover_rast["YEAR-OF-CHANGE"] | ||
|
||
|
||
|
||
# HERBACEOUS COVER CHANGE (VALUE OF SEASONAL APLITUDE) | ||
####################################################################### | ||
|
||
|
||
fname <- dir(dinp, ".*HL_TSA_LNDLG_SMA_VSA-CAO.vrt$", full.names=TRUE) | ||
|
||
herbaceous_cover_rast <- rast(fname) | ||
|
||
herbaceous_cover_changes <- herbaceous_cover_rast$CHANGE | ||
herbaceous_cover_year_of_change <- herbaceous_cover_rast["YEAR-OF-CHANGE"] | ||
|
||
|
||
|
||
# VALUE OF PEAK SEASON | ||
####################################################################### | ||
|
||
fname <- dir(dinp, ".*HL_TSA_LNDLG_SMA_VPS-CAO.vrt$", full.names=TRUE) | ||
|
||
peak_rast <- rast(fname) | ||
|
||
peak_changes <- peak_rast$CHANGE | ||
peak_year_of_change <- peak_rast["YEAR-OF-CHANGE"] | ||
|
||
|
||
|
||
# FOR REFERENCE: SAVE RASTERS | ||
####################################################################### | ||
|
||
#writeRaster(woody_cover_changes, "woody_cover_chg_ref.tif") | ||
#writeRaster(woody_cover_year_of_change, "woody_cover_yoc_ref.tif") | ||
|
||
#writeRaster(herbaceous_cover_changes, "herbaceous_cover_chg_ref.tif") | ||
#writeRaster(herbaceous_cover_year_of_change, "herbaceous_cover_yoc_ref.tif") | ||
|
||
#writeRaster(peak_changes, "peak_chg_ref.tif") | ||
#writeRaster(peak_year_of_change, "peak_yoc_ref.tif") | ||
|
||
|
||
|
||
|
||
# COMPARE TESTRUN WITH REFERENCE EXECUTION | ||
####################################################################### | ||
failure <- FALSE | ||
|
||
woody_cover_changes_result <- all.equal(woody_cover_changes, woody_cover_changes_ref) | ||
if (is.character(woody_cover_changes_result)) { | ||
print(paste0("Error: ", woody_cover_changes_result, " for woody cover changes.")) | ||
failure <- TRUE | ||
} else { | ||
print("Woody cover change check passed.") | ||
} | ||
|
||
woody_cover_year_of_change_result <- all.equal(woody_cover_year_of_change, woody_cover_year_of_change_ref) | ||
if (is.character(woody_cover_year_of_change_result)) { | ||
print(paste0("Error: ", woody_cover_year_of_change_result, " for woody cover year of change.")) | ||
failure <- TRUE | ||
} else { | ||
print("Woody cover year of change check passed.") | ||
} | ||
|
||
|
||
herbaceous_cover_changes_result <- all.equal(herbaceous_cover_changes, herbaceous_cover_changes_ref) | ||
if (is.character(herbaceous_cover_changes_result)) { | ||
print(paste0("Error: ",herbaceous_cover_changes_result, " for herbaceous cover changes.")) | ||
failure <- TRUE | ||
} else { | ||
print("Herbaceous cover change check passed.") | ||
} | ||
|
||
herbaceous_cover_year_of_change_result <- all.equal(herbaceous_cover_year_of_change, herbaceous_cover_year_of_change_ref) | ||
if (is.character(herbaceous_cover_year_of_change_result)) { | ||
print(paste0("Error: ", herbaceous_cover_year_of_change_result, " for herbaceous cover year of change.")) | ||
failure <- TRUE | ||
} else { | ||
print("Herbaceous cover year of change check passed.") | ||
} | ||
|
||
|
||
peak_changes_result <- all.equal(peak_changes, peak_changes_ref) | ||
if (is.character(peak_changes_result)) { | ||
print(paste0("Error: ", peak_changes_result, " for peak changes.")) | ||
failure <- TRUE | ||
} else { | ||
print("Peak change check passed.") | ||
} | ||
|
||
|
||
peak_year_of_change_result <- all.equal(peak_year_of_change, peak_year_of_change_ref) | ||
if (is.character(peak_year_of_change_result)) { | ||
print(paste0("Error: ", peak_year_of_change_result, " for peak year of change.")) | ||
failure <- TRUE | ||
} else { | ||
print("Peak year of change check passed.") | ||
} | ||
|
||
if (failure) { | ||
stop("Some test failed.") | ||
} else { | ||
print("All checks passed.") | ||
} |
Oops, something went wrong.