gDRstyle 1.7.2
A style guide for the gdrplatform organization.
if ( over if(1 == 1 over 1==1if (1 == 1) {} over if (1=1){}[ , subset] over [, subset]<- over =validated_se <- validate_SE() over validate_se <- validate_SE()function(a = "A") over function(a="A")function(big_matrix) over function(bigMatrix)compute_metrics_SE over metrics_SE.get*, setters should start with set*, boolean checkers should start with is* # Good
fun <- function(param1,
                param2,
                param_with_dir_for_st_important = get_st_important_dir()) {
  # Code is indented by two spaces.
  ...
}
 # Bad
fun <- function(param1, param2, param_with_dir_for_st_important = file.path(system.file(paste(param1, "SE", "rds", sep = "."), package = "important_package"))) {
  ...
}<- over = to differentiate function arguments assignments from function assignments myFunction <- function() over myFunction = function()assert tests for their parametersvapply over sapply (or lapply + unlist() if predefining FUN.VALUE is difficult)apply on data.frame(s) (mapply is good for row-wise operations)  # Good.
  foo <- function() {
    # Do stuff.
    x
  }
  # Bad.
  foo <- function() {
    # Do stuff.
    return(x)
  }if and else statements should be surrounded by curly braces on the same lineif (TRUE) {
  NULL
} else {
  NULL
}## NULLwhat_is_going_on <- if (is_check()) {
  flog <- "it's getting hot..."
} else if (is_mate()) {
  flog <- "Oh noooo..."
} else {
  flog <- "there is a hope..."
}R/ (R/assays => tests/testthat/test-assays.R)package.Rpackage.R
checkmate, SummarizedExperiment, etc.expect_equal(obs, exp) over expect_equal(exp, obs)^ over ** for exponentiation like 2 ^ 3 over 2**3.0’s in front of decimals like 0.1 over .1df[, "alias"] <- df[, "celllinename"] over df[, 1] <- df[, 2]df[, fxn_that_returns_idx(x):length(x)] <- NA over df[, 2:length(x)] <- NA# Good.
idx <- foo()
if (length(idx) == 1) {
  f <- c(f[idx], f[-idx])
}
# Bad.
if (length(foo()) == 1) {
  f <- c(f[foo()], f[foo()])
}usethis::use_package_doc()#' @note To learn more about functions start with `help(package = "{pkgname}")` 
#' @keywords internal
#' @return package help page
"_PACKAGE"## [1] "_PACKAGE"Roxygen: list(markdown = TRUE)@import or @importFrom always in one place - file package.Rnamespace::function_namegDRstyle::checkPackage() (use bioc_check = TRUE to verify
if the requirements for Bioconductor are also met)<type>: <description> where type can be one of:
fix: for bugfixes;feat: for new features;docs: for documentation changes;style: for formatting changes that do not affect the meaning of the code;test: for adding missing tests or correcting existing tests;refactor: for code changes that neither fixes a bug nor adds a featureci: for changes to CI configurationPATCH version;MINOR version.
Exceptions: All public packages - as to-be-released on Bioconductor have version 0.99.x.MINOR version regardless of the nature of the changes.sessionInfo()## R version 4.5.0 (2025-04-11 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows Server 2022 x64 (build 20348)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=C                          
## [2] LC_CTYPE=English_United States.utf8   
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## 
## time zone: America/New_York
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] gDRstyle_1.7.2   BiocStyle_2.37.0
## 
## loaded via a namespace (and not attached):
##  [1] cli_3.6.5           knitr_1.50          rlang_1.1.6        
##  [4] xfun_0.52           rex_1.2.1           jsonlite_2.0.0     
##  [7] glue_1.8.0          backports_1.5.0     htmltools_0.5.8.1  
## [10] sass_0.4.10         rmarkdown_2.29      evaluate_1.0.3     
## [13] jquerylib_0.1.4     fastmap_1.2.0       yaml_2.3.10        
## [16] lifecycle_1.0.4     bookdown_0.43       BiocManager_1.30.25
## [19] compiler_4.5.0      lintr_3.2.0         digest_0.6.37      
## [22] R6_2.6.1            bslib_0.9.0         tools_4.5.0        
## [25] lazyeval_0.2.2      xml2_1.3.8          cachem_1.1.0       
## [28] desc_1.4.3