-
Notifications
You must be signed in to change notification settings - Fork 928
Package Conventions
Want to add a code to Seurat? This document is intended to provide a description of the expected behavior/naming conventions for functions and their parameters.
In general, we try to follow Google's R Style Guide.
In the function definition, include a verbose
parameter to allow the user to specify whether to print the output. This should take a boolean.
If the function is write any output to the console, there are several options to choose from to print messages. Here's what you should use and when:
-
message
: Should be the default, except in the cases listed below. -
cat
: Use when designing ashow
method or anyprint.*
S3 methods. -
warning
: Function is allowed to proceed but user should be notified (higher priority notification than message) -
stop
: Function should quit and print this message. -
print
: Never use print
Progress bars are great. If you want to add a progress bar to a function that uses:
- for loops - initialize the progress bar with:
pb <- txtProgressBar(char = '=', style = 3)
And update in each loop iteration with:
setTxtProgressBar(pb = pb, value = i)
-
apply
- use functions from thepbapply
package. -
c++ code, use the RcppEigen package. Include the header file
#include <progress.hpp>
and
// [[Rcpp::depends(RcppProgress)]]
in the .cpp
file. In the function, create the progress bar with
Progress p(num_iterations, display_progress);
and update with
p.increment();