This function transforms a `tof_tibble` of transformed ion counts from a mass cytometer back into something that looks more like an .fcs file that Fluidigm software generates.
Arguments
- tof_tibble
A `tof_tibble` or a `tibble`.
- channel_cols
A vector of non-quoted column names indicating which columns in `tof_tibble` contain protein measurements. Supports tidyselect helpers. If nothing is specified, the default is to transform all numeric columns.
- redo_noise
A boolean value indicating whether to add uniform noise that to each CyTOF measurement for aesthetic and visualization purposes. See this paper. Defaults to FALSE
- transform_fun
A vectorized function to apply to each column specified by `channel_cols` for post-processing. Defaults to
rev_asinh
transformation (with a cofactor of 5).
Value
A `tof_tbl` with identical dimensions to the input `tof_tibble`, with all columns specified in channel_cols transformed using `transform_fun` (with noise added or not removed depending on `redo_noise`).
Examples
# read in an example .fcs file from tidytof's internal datasets
input_file <- dir(tidytof_example_data("aml"), full.names = TRUE)[[1]]
tof_tibble <- tof_read_data(input_file)
# preprocess all numeric columns with default behavior
# arcsinh transformation with a cofactor of 5
preprocessed_tof_tibble <- tof_preprocess(tof_tibble)
# postprocess all numeric columns to reverse the preprocessing
tof_postprocess(tof_tibble)
#> # A tibble: 100 × 59
#> Time Event_length `CD45|Y89` `empty|Pd102` `empty|Pd104` `empty|Pd105`
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Inf 22215276. 6.00e224 8.82 1411688. Inf
#> 2 Inf 446205752. Inf 135. 859679. Inf
#> 3 Inf 22215276. Inf 2634. 321. 8.51e277
#> 4 Inf 22215276. 2.24e254 3.47 1383. 8.29e254
#> 5 Inf 164149923. Inf 127. 38726. 3.70e280
#> 6 Inf 446205752. 1.14e211 163. 116. 3.29e272
#> 7 Inf 22215276. 2.62e219 79.1 175. 1.82e246
#> 8 Inf 164149923. 5.35e246 1876. 291228. 5.64e305
#> 9 Inf 446205752. Inf 55.3 24727. Inf
#> 10 Inf 22215276. 2.38e236 5.05 2010273. Inf
#> # ℹ 90 more rows
#> # ℹ 53 more variables: `empty|Pd106` <dbl>, `empty|Pd108` <dbl>,
#> # `empty|Pd110` <dbl>, `CD61|In113` <dbl>, `CD99|In115` <dbl>,
#> # `empty|I127` <dbl>, `CD45RA|La139` <dbl>, `CD93|Ce140` <dbl>,
#> # `CD3_CD19|Pr141` <dbl>, `CCR2|Nd142` <dbl>, `CD117|Nd143` <dbl>,
#> # `CD123|Nd144` <dbl>, `CD64|Nd145` <dbl>, `CD90|Nd146` <dbl>,
#> # `CD38|Sm147` <dbl>, `CD34|Nd148` <dbl>, `CEBPa|Sm149` <dbl>, …