Skip to content

Commit 73611ae

Browse files
Reformat with air
1 parent 3831393 commit 73611ae

36 files changed

+7262
-6587
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
^inst/manuscript$
1313
^\.github$
1414
^CODE_OF_CONDUCT\.md$
15+
^air.toml$
16+
^\.vscode$

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[r]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "Posit.air-vscode"
5+
}
6+
}

R/cellbrowsers.R

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,66 @@
2626
#' )
2727
#' }
2828
#' @export
29-
get_ucsc_reference <- function(cb_url,
30-
cluster_col,
31-
...) {
32-
if (!requireNamespace("R.utils", quietly = TRUE)) {
33-
stop(
34-
"This function requires the R.utils package, please install\n",
35-
"install.packages('R.utils')"
36-
)
37-
}
29+
get_ucsc_reference <- function(cb_url, cluster_col, ...) {
30+
if (!requireNamespace("R.utils", quietly = TRUE)) {
31+
stop(
32+
"This function requires the R.utils package, please install\n",
33+
"install.packages('R.utils')"
34+
)
35+
}
3836

39-
if (!requireNamespace("data.table", quietly = TRUE)) {
40-
stop(
41-
"This function requires the data.table package, please install\n",
42-
"install.packages('data.table')"
43-
)
44-
}
37+
if (!requireNamespace("data.table", quietly = TRUE)) {
38+
stop(
39+
"This function requires the data.table package, please install\n",
40+
"install.packages('data.table')"
41+
)
42+
}
4543

46-
url <- httr::parse_url(cb_url)
47-
base_url <- url
48-
ds <- url$query$ds
44+
url <- httr::parse_url(cb_url)
45+
base_url <- url
46+
ds <- url$query$ds
4947

50-
# ds can include sub-datasets with syntax, "dataset+subdataset+and-so-on"
51-
# files are hosted at urls: dataset/subdataset/andsoon/..."
52-
ds_split <- strsplit(ds, "+", fixed = TRUE)[[1]]
53-
ds <- paste0(ds_split, collapse = "/")
54-
base_url$query <- ""
48+
# ds can include sub-datasets with syntax, "dataset+subdataset+and-so-on"
49+
# files are hosted at urls: dataset/subdataset/andsoon/..."
50+
ds_split <- strsplit(ds, "+", fixed = TRUE)[[1]]
51+
ds <- paste0(ds_split, collapse = "/")
52+
base_url$query <- ""
5553

56-
mdata_url <- httr::modify_url(base_url,
57-
path = file.path(ds, "meta.tsv")
58-
)
59-
if (!httr::http_error(mdata_url)) {
60-
mdata <- data.table::fread(mdata_url, data.table = FALSE, sep = "\t")
61-
} else {
62-
stop("unable to find metadata at url: ", mdata_url)
63-
}
54+
mdata_url <- httr::modify_url(base_url, path = file.path(ds, "meta.tsv"))
55+
if (!httr::http_error(mdata_url)) {
56+
mdata <- data.table::fread(mdata_url, data.table = FALSE, sep = "\t")
57+
} else {
58+
stop("unable to find metadata at url: ", mdata_url)
59+
}
6460

65-
mat_url <- httr::modify_url(base_url,
66-
path = file.path(ds, "exprMatrix.tsv.gz")
67-
)
68-
if (!httr::http_error(mat_url)) {
69-
mat <- data.table::fread(mat_url, data.table = FALSE, sep = "\t")
70-
} else {
71-
stop("unable to find matrix at url: ", mat_url)
72-
}
61+
mat_url <- httr::modify_url(
62+
base_url,
63+
path = file.path(ds, "exprMatrix.tsv.gz")
64+
)
65+
if (!httr::http_error(mat_url)) {
66+
mat <- data.table::fread(mat_url, data.table = FALSE, sep = "\t")
67+
} else {
68+
stop("unable to find matrix at url: ", mat_url)
69+
}
7370

74-
rownames(mat) <- mat[, 1]
75-
mat[, 1] <- NULL
76-
mat <- as.matrix(mat)
71+
rownames(mat) <- mat[, 1]
72+
mat[, 1] <- NULL
73+
mat <- as.matrix(mat)
7774

78-
mm <- max(mat)
75+
mm <- max(mat)
7976

80-
if (mm > 50) {
81-
dots <- list(...)
82-
if (!"if_log" %in% names(dots) || dots$if_log) {
83-
warning(
84-
"the data matrix has a maximum value of ", mm, "\n",
85-
"the data are likely not log transformed,\n",
86-
"please set the if_log argument for average clusters accordingly"
87-
)
88-
}
77+
if (mm > 50) {
78+
dots <- list(...)
79+
if (!"if_log" %in% names(dots) || dots$if_log) {
80+
warning(
81+
"the data matrix has a maximum value of ",
82+
mm,
83+
"\n",
84+
"the data are likely not log transformed,\n",
85+
"please set the if_log argument for average clusters accordingly"
86+
)
8987
}
88+
}
9089

91-
average_clusters(mat, mdata, cluster_col = cluster_col, ...)
90+
average_clusters(mat, mdata, cluster_col = cluster_col, ...)
9291
}

0 commit comments

Comments
 (0)