-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: Add a GHA Linter #79
Changes from all commits
19c8af5
f070c1a
286ce4c
03a97a3
3f1c910
0ab67ce
8a72a0c
1500f9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
.git | ||
.github | ||
misc | ||
^\.github$ | ||
.lintr | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is autogenerated by using the tool |
||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
name: lint-project.yaml | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
lint-project: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- name: Install lintr | ||
run: install.packages("lintr") | ||
shell: Rscript {0} | ||
|
||
- name: Lint root directory | ||
run: lintr::lint_dir() | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
linters: linters_with_defaults( | ||
line_length_linter(120), | ||
commented_code_linter = NULL, | ||
object_usage_linter = NULL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This last one is useful, but there is a bug in the way lintr works where it views internal functions and references to them as undeclared globals. I have too many internal functions to ignore each line, so disabling this for now. We could circumvent this by installing the package before linting, but that would requiring installing seurat and hdf5r which takes forever to install. See here for more information |
||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,11 @@ | |
#' | ||
#' @noRd | ||
louper_create_cloupe <- function( | ||
h5path, | ||
output_dir = NULL, | ||
output_name = NULL, | ||
executable_path = NULL, | ||
force = FALSE | ||
) { | ||
h5path, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code was auto formatted with |
||
output_dir = NULL, | ||
output_name = NULL, | ||
executable_path = NULL, | ||
force = FALSE) { | ||
# default loupe name to `converted.cloupe` | ||
if (is.null(output_name)) { | ||
output_name <- "converted" | ||
|
@@ -54,10 +53,10 @@ louper_create_cloupe <- function( | |
return(err(sprintf("cannot find Louper executable at path: '%s'", executable_path))) | ||
} | ||
|
||
cmd_msg <- sprintf('running command: "%s"', paste(c(executable_path, args), collapse=" ")) | ||
logMsg(cmd_msg) | ||
cmd_msg <- sprintf('running command: "%s"', paste(c(executable_path, args), collapse = " ")) | ||
log_msg(cmd_msg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the name to |
||
|
||
status <- system2(command=executable_path, args=args) | ||
status <- system2(command = executable_path, args = args) | ||
|
||
if (status == 0) { | ||
return(SUCCESS) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,32 @@ err <- function(msg) { | |
|
||
#' The non-error variant of above | ||
#' @noRd | ||
SUCCESS <- list(success = TRUE, msg = NULL) | ||
SUCCESS <- list(success = TRUE, msg = NULL) # nolint | ||
|
||
#' validation error with link to 10x support | ||
#' @noRd | ||
validation_err <- function(msg, name) { | ||
sprintf("\nIt looks like the formatting of your %s does not match the required formatting for LoupeR. For further information, please see the documentation: 10xgen.com/louper\n\n%s", name, msg) | ||
sprintf( | ||
paste( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
"\nIt looks like the formatting of your %s does not match the required formatting for LoupeR.", | ||
"For further information, please see the documentation: 10xgen.com/louper\n\n%s" | ||
), | ||
name, | ||
msg | ||
) | ||
} | ||
|
||
#' general error with link to 10x support | ||
#' @noRd | ||
general_err <- function(msg, name) { | ||
sprintf("\nIt looks like there was an issue with %s. For further information, please see the documentation: 10xgen.com/louper\n\n%s", name, msg) | ||
sprintf( | ||
paste( | ||
"\nIt looks like there was an issue with %s. For further information,", | ||
"please see the documentation: 10xgen.com/louper\n\n%s", | ||
), | ||
name, | ||
msg | ||
) | ||
} | ||
|
||
#' Create a Bugreport from a Seurat Object | ||
|
@@ -49,15 +63,15 @@ create_bugreport_from_seurat <- function(obj) { | |
} | ||
|
||
# overview | ||
namedAssay <- select_assay(obj) | ||
if (is.null(namedAssay)) { | ||
named_assay <- select_assay(obj) | ||
if (is.null(named_assay)) { | ||
cat("\nSeurat:\n\n") | ||
cat("No assay found\n") | ||
return(invisible()) | ||
} | ||
|
||
assay_name <- names(namedAssay) | ||
assay <- namedAssay[[1]] | ||
assay_name <- names(named_assay) | ||
assay <- named_assay[[1]] | ||
clusters <- select_clusters(obj) | ||
projections <- select_projections(obj) | ||
counts <- counts_matrix_from_assay(assay) | ||
|
@@ -78,24 +92,25 @@ create_bugreport_from_seurat <- function(obj) { | |
#' This bugreport can then be included when reaching out to 10xGenomics Support or when filing | ||
#' a Github ticket. This information should be included along with any other output when creating a Loupe file. | ||
#' | ||
#' @param count_mat A sparse dgCMatrix as is generated via Matrix::rsparsematrix. Rows are features, Columns are barcodes. | ||
#' @param count_mat A sparse dgCMatrix as is generated via Matrix::rsparsematrix. | ||
#' Rows are features, Columns are barcodes. | ||
#' @param clusters list of factors that hold information for each barcode | ||
#' @param projections list of matrices, all with dimensions (barcodeCount x 2) | ||
#' @param assay_name optional string that holds the Seurat Object assay name. | ||
#' @param seurat_obj_version optional string that holds the Seurat Object version. It is useful for debugging compatibility issues. | ||
#' @param seurat_obj_version optional string that holds the Seurat Object version. | ||
#' It is useful for debugging compatibility issues. | ||
#' @param skip_metadata optional logical which skips printing metadata | ||
#' | ||
#' @importFrom methods is | ||
#' | ||
#' @export | ||
create_bugreport <- function( | ||
count_mat, | ||
clusters, | ||
projections, | ||
assay_name = NULL, | ||
seurat_obj_version = NULL, | ||
skip_metadata = FALSE | ||
) { | ||
count_mat, | ||
clusters, | ||
projections, | ||
assay_name = NULL, | ||
seurat_obj_version = NULL, | ||
skip_metadata = FALSE) { | ||
# metadata | ||
if (!skip_metadata) { | ||
cat("\nMetadata:\n\n") | ||
|
@@ -118,8 +133,8 @@ create_bugreport <- function( | |
cat("\nMatrix Sampling:\n\n") | ||
all_features <- rownames(count_mat) | ||
all_barcodes <- colnames(count_mat) | ||
features <- sample(rownames(count_mat), size=min(10, length(all_features))) | ||
barcodes <- sample(colnames(count_mat), size=min(10, length(all_barcodes))) | ||
features <- sample(rownames(count_mat), size = min(10, length(all_features))) | ||
barcodes <- sample(colnames(count_mat), size = min(10, length(all_barcodes))) | ||
cat(sprintf("feature count: %d\n", length(all_features))) | ||
cat(sprintf("barcode count: %d\n", length(all_barcodes))) | ||
cat(sprintf("feature sampling:\n")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lintr
is the R linting library and the file.lintr
is its configuration.