Skip to content

Commit d995beb

Browse files
authored
trim the comments that were review notes (#55)
The recent bug fixes left comments explaining why the change was correct, which is PR material rather than something the next reader of the code needs. Keep the one-line narrating comments, drop the justifications.
1 parent 0a0174d commit d995beb

5 files changed

Lines changed: 7 additions & 15 deletions

File tree

src/data_processors/process_dataset/script.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ if (ad2_mod == "ATAC") {
9090
# subset to make the task computationally feasible
9191
if (ncol(ad2) > 10000) {
9292
poss_ix <- which(Matrix::colSums(ad2$layers[["normalized"]]) > 0)
93-
# sample by position -- sample(x, n) errors when n > length(x), and treats a
94-
# length-1 x as seq_len(x)
93+
# sample by position -- sample(x, n) treats a length-1 x as seq_len(x)
9594
sel_ix <- sort(poss_ix[sample.int(length(poss_ix), min(10000, length(poss_ix)))])
9695
ad2 <- ad2[, sel_ix]$copy()
9796
ad2_var <- ad2_var[sel_ix, , drop = FALSE]
@@ -109,9 +108,8 @@ if ("is_train" %in% colnames(ad1$obs)) {
109108
is_train <- which(ad1$obs[["is_train"]] == "train")
110109
is_test <- which(ad1$obs[["is_train"]] != "train")
111110
} else {
112-
# No predefined split -- obs['is_train'] carries the NeurIPS 2021 competition
113-
# split and other datasets have no reason to have it. Hold out a quarter of the
114-
# batches instead, so the test cells come from donors the method has not seen.
111+
# no predefined split -- hold out a quarter of the batches, so the test cells
112+
# come from donors the method has not seen
115113
batches <- unique(as.character(ad1$obs[["batch"]]))
116114
if (length(batches) > 1) {
117115
test_batches <- sample(batches, max(1, floor(length(batches) / 4)))

src/methods/lm/script.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ix <- seq_len(nrow(input_train_mod1))
3131
dr_train <- dr[ix, , drop = FALSE]
3232
dr_test <- dr[-ix, , drop = FALSE]
3333

34-
# add an intercept column -- fastLm() uses the design matrix as is
34+
# add an intercept column
3535
dr_train <- cbind(intercept = 1, dr_train)
3636
dr_test <- cbind(intercept = 1, dr_test)
3737

src/methods/novel/novel_predict/script.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595
dataloader_test = DataLoader(dataset_test, 32, shuffle = False, num_workers = 4)
9696

9797
outputs = []
98-
# the weights are loaded with map_location='cpu', so move the model onto the device
99-
# we selected above -- otherwise this component requests a GPU and never uses it
10098
model = model.to(device)
10199
model.eval()
102100
with torch.no_grad():

src/metrics/correlation/script.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ pv_sd2 <- proxyC::colSds(pv)
3939
tv_sd1 <- proxyC::rowSds(tv)
4040
pv_sd1 <- proxyC::rowSds(pv)
4141

42-
# correlate matching rows (margin 1) or columns (margin 2) of two matrices.
43-
# dynutils::calculate_similarity() would do this too, but it ends in as.matrix(),
44-
# densifying an n x n / p x p matrix just so we can read its diagonal.
42+
# correlate matching rows (margin 1) or columns (margin 2) of two matrices
4543
paired_similarity <- function(x, y, margin, method) {
4644
if (margin == 1) {
4745
x <- Matrix::t(x)
@@ -87,8 +85,7 @@ mean_spearman_per_gene <- mean(spearman_vec_2)
8785
tv_vec <- as.vector(tv)
8886
pv_vec <- as.vector(pv)
8987

90-
# a constant prediction has no correlation to speak of -- score it as 0, the same
91-
# substitution the per-cell and per-gene metrics make above. cor() would return NA.
88+
# zero variance -- score as 0, like the per-cell and per-gene metrics above
9289
if (sd(tv_vec) == 0 || sd(pv_vec) == 0) {
9390
overall_pearson <- 0
9491
overall_spearman <- 0

src/metrics/mse/script.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
logging.info("Computing MSE metrics")
2828

29-
# coerce to sparse -- a method is free to return a dense layer, and
30-
# sparse - dense yields a np.matrix, which has no .power()
29+
# coerce to sparse -- sparse minus dense yields a np.matrix, which has no .power()
3130
tmp = csr_matrix(ad_sol.layers["normalized"]) - csr_matrix(ad_pred.layers["normalized"])
3231
rmse = np.sqrt(tmp.power(2).mean())
3332
mae = np.abs(tmp).mean()

0 commit comments

Comments
 (0)