3
3
' audit
4
4
5
5
Usage:
6
- audit.R -b <id> -m <id> -o <file> [-a <int>] [-l <file>] [-s <query>] [-p <var>] [-f <str>] [-r <op>] [-t <dir>]
6
+ audit.R -b <id> -m <id> -o <file> [-a <int>] [-l <file>] [-s <query>] [-p <var>] [-f <str>] [-r <op>] [-t <dir>] [-q <var>]
7
7
8
8
Options:
9
9
-h --help Show this screen.
@@ -16,7 +16,8 @@ Options:
16
16
-f <str> --suffix=<str> Suffix to append to barcode to select a profile file [default: _normalized_variable_selected.csv].
17
17
-p <var> --group_by=<var> Group by column [default: Metadata_Well].
18
18
-r <op> --operation=<op> Audit operation [default: replicate_quality].
19
- -t <dir> --tmpdir=<dir> Temporary directory [default: /tmp]. ' - > doc
19
+ -t <dir> --tmpdir=<dir> Temporary directory [default: /tmp].
20
+ -q <var> --null_quantile=<var> Quantile of null distribution to extract [default: 0.95]' - > doc
20
21
21
22
suppressWarnings(suppressMessages(library(docopt )))
22
23
@@ -46,6 +47,8 @@ group_by <- stringr::str_split(opts[["group_by"]], ",")[[1]]
46
47
47
48
operation <- opts [[" operation" ]]
48
49
50
+ null_quantile <- as.numeric(paste(opts [[" null_quantile" ]]))
51
+
49
52
backend_dir <- paste(" ../.." , " backend" , batch_id , sep = " /" )
50
53
51
54
metadata_dir <- paste(" ../.." , " metadata" , batch_id , sep = " /" )
@@ -56,15 +59,15 @@ filelist <- barcode_platemap %>%
56
59
filter(Plate_Map_Name == plate_map_name ) %> %
57
60
mutate(filename = normalizePath(paste0(backend_dir , " /" , Assay_Plate_Barcode , " /" , Assay_Plate_Barcode , suffix )))
58
61
59
- df <- filelist $ filename %> %
62
+ df <- filelist $ filename %> %
60
63
map_df(
61
64
function (filename ) {
62
65
if (file.exists(filename )) {
63
66
suppressMessages(readr :: read_csv(filename ))
64
-
67
+
65
68
} else {
66
69
tibble :: data_frame()
67
-
70
+
68
71
}
69
72
}
70
73
)
@@ -101,22 +104,23 @@ set.seed(24)
101
104
correlations <- df %> %
102
105
median_pairwise_correlation(variables , group_by )
103
106
104
- null_threshold <-
105
- 1 : iterations %> %
107
+ null_threshold <-
108
+ 1 : iterations %> %
106
109
map_df(function (i ) {
107
110
df %> %
108
111
tidyr :: unite_(" group_by" , group_by ) %> %
109
112
mutate(group_by = sample(group_by )) %> %
110
113
median_pairwise_correlation(variables , " group_by" )
111
114
}) %> %
112
115
magrittr :: extract2(" correlation" ) %> %
113
- quantile(0.95 , na.rm = TRUE )
116
+ quantile(null_quantile , na.rm = TRUE )
114
117
115
118
result <-
116
119
tibble :: data_frame(
117
120
plate_map_name = plate_map_name ,
118
121
null_threshold = null_threshold ,
119
- fraction_strong = (sum(correlations $ correlation > null_threshold ) / nrow(correlations ))
122
+ fraction_strong = (sum(correlations $ correlation > null_threshold ) / nrow(correlations )),
123
+ null_quantile = null_quantile
120
124
)
121
125
122
126
knitr :: kable(result )
0 commit comments