@@ -201,6 +201,14 @@ sleuth_prep <- function(
201
201
msg(' reading in kallisto results' )
202
202
sample_to_covariates $ sample <- as.character(sample_to_covariates $ sample )
203
203
204
+ if (nrow(sample_to_covariates ) == 1 && ! is.null(full_model )) {
205
+ warning(" There is only one sample present, but you also provided a model. " ,
206
+ " The model will be set to NULL to prevent downstream errors.\n " ,
207
+ " The sample can be viewed using sleuth_live after preparation, " ,
208
+ " but you need more than one sample to run the other aspects of Sleuth." )
209
+ full_model <- NULL
210
+ }
211
+
204
212
kal_dirs <- sample_to_covariates $ path
205
213
sample_to_covariates $ path <- NULL
206
214
@@ -280,7 +288,7 @@ sleuth_prep <- function(
280
288
filter_true <- filter_bool [filter_bool ]
281
289
282
290
msg(paste0(sum(filter_bool ), ' targets passed the filter' ))
283
- est_counts_sf <- norm_fun_counts(est_counts_spread [filter_bool , ])
291
+ est_counts_sf <- norm_fun_counts(est_counts_spread [filter_bool , , drop = FALSE ])
284
292
285
293
filter_df <- adf(target_id = names(filter_true ))
286
294
@@ -298,7 +306,7 @@ sleuth_prep <- function(
298
306
msg(" normalizing tpm" )
299
307
tpm_spread <- spread_abundance_by(obs_raw , " tpm" ,
300
308
sample_to_covariates $ sample )
301
- tpm_sf <- norm_fun_tpm(tpm_spread [filter_bool , ])
309
+ tpm_sf <- norm_fun_tpm(tpm_spread [filter_bool , , drop = FALSE ])
302
310
tpm_norm <- as_df(t(t(tpm_spread ) / tpm_sf ))
303
311
tpm_norm $ target_id <- rownames(tpm_norm )
304
312
tpm_norm <- tidyr :: gather(tpm_norm , sample , tpm , - target_id )
@@ -473,10 +481,10 @@ sleuth_prep <- function(
473
481
# This is the rest of the gene_summary code
474
482
if (ret $ gene_mode ) {
475
483
names(sigma_q_sq ) <- which_agg_id
476
- obs_counts <- obs_to_matrix(ret , " scaled_reads_per_base" )[which_agg_id , ]
484
+ obs_counts <- obs_to_matrix(ret , " scaled_reads_per_base" )[which_agg_id , , drop = FALSE ]
477
485
} else {
478
486
names(sigma_q_sq ) <- which_target_id
479
- obs_counts <- obs_to_matrix(ret , " est_counts" )[which_target_id , ]
487
+ obs_counts <- obs_to_matrix(ret , " est_counts" )[which_target_id , , drop = FALSE ]
480
488
}
481
489
482
490
sigma_q_sq <- sigma_q_sq [order(names(sigma_q_sq ))]
@@ -562,7 +570,7 @@ check_target_mapping <- function(t_id, target_mapping) {
562
570
# ' @export
563
571
norm_factors <- function (mat ) {
564
572
nz <- apply(mat , 1 , function (row ) ! any(round(row ) == 0 ))
565
- mat_nz <- mat [nz , ]
573
+ mat_nz <- mat [nz , , drop = FALSE ]
566
574
p <- ncol(mat )
567
575
geo_means <- exp(apply(mat_nz , 1 , function (row ) mean(log(row ))))
568
576
s <- sweep(mat_nz , 1 , geo_means , `/` )
@@ -718,7 +726,7 @@ obs_to_matrix <- function(obj, value_name) {
718
726
rownames(obs_counts ) <- obs_counts $ target_id
719
727
obs_counts $ target_id <- NULL
720
728
obs_counts <- as.matrix(obs_counts )
721
- obs_counts <- obs_counts [, obj $ sample_to_covariates $ sample ]
729
+ obs_counts <- obs_counts [, obj $ sample_to_covariates $ sample , drop = FALSE ]
722
730
723
731
obs_counts
724
732
}
0 commit comments