Generate conversion factors for fluorescent protein (FP) calibrations.
Originally based on flopr::generate_cfs()
but with numerous changes. The
original function was intended for fluorescein and microsphere calibrations,
whereas this one can be used for any fluorescent calibrant, including
proteins. Takes as input a parsed CSV of fluorescence data of a dilution
series of FPs at one or more gains, that contains both data and metadata
columns (including: instrument
, plate
, seal
, channel_name
,
channel_ex
, channel_em
, media
, calibrant
, protein
, replicate
,
volume
, mw_gmol1
, concentration_ngul
, well
, the columns for the
fluorescence data, row
, column
). A number of arguments allow the tweaking
of the original data set. Following this, the data is reshaped, normalised,
trimmed of saturated points, summarised and used to fit a model for the
conversion factors from arbitrary to absolute units. Optional extras: the
sensitivity_plots
argument extends this analysis to identify the limits of
detection and relative sensitivity and dynamic range of each gain. Plots are
saved to record the processed data at every step, allowing for visual sanity
checks and troubleshooting. A CSV file with the fitted conversion factors is
saved (along with the processed data if requested with more_csvs
).
Usage
generate_cfs(
calibration_csv,
more_csvs = FALSE,
more_plots = FALSE,
sensitivity_plots = FALSE,
include_only = NULL,
exclude = NULL,
gain_fix = FALSE,
rename_from = NULL,
rename_to = NULL,
subset_rows = FALSE,
rows_to_keep = c("C", "D"),
separator = "",
complete_blank = FALSE,
outfolder = "."
)
Arguments
- calibration_csv
character string. Path of the calibration data CSV file.
- more_csvs
logical. Optionally save all the intermediate tables in this function. Defaults to FALSE.
- more_plots
logical. Optionally save more plots. Defaults to FALSE.
- sensitivity_plots
logical. Optionally adds a few extra columns to the data such as the min/max normalised fluorescence and detectable molecules. It also plots a few extra plots. Defaults to FALSE.
- include_only
character string. If specified, only includes the measures (column names) specified here.
- exclude
character string. If specified, excludes any measures (column names) specified here.
- gain_fix
logical. Optionally add "0" before 2-digit gain names i.e. 'GFP 40' -> 'GFP 040', or
blueblue 40
->blueblue 040
- which fixes ordering of plots. Defaults to FALSE.- rename_from
character string. Rename measures (column names) containing character string
rename_from
to character string specified inrename_to
. Bothrename_from
andrename_to
need to be completed to trigger renaming.- rename_to
character string. Rename measures (column names) containing character string
rename_from
to character string specified inrename_to
. Bothrename_from
andrename_to
need to be completed to trigger renaming.- subset_rows
logical. Should script take a subset of the rows (or whole table)? Defaults to FALSE.
- rows_to_keep
character array. If
subset_rows
is TRUE, script will choose rows to keep from this list. Defaults toc("C","D")
.- separator
character string that represents the separator between the channel name and the gain value in the measures columns, e.g. for "GFP 40" it is " ", for "GFP40" it is "" and for "GFP_40" it is "_". Required for plotting the gain vs conversion factors. Defaults to "".
- complete_blank
logical. Optionally adds "0" to the
concentration_ngul
column for wells identified as blank (protein
= "none"). Useful if metadata is missing these values. Defaults to FALSE.- outfolder
character string. Path to folder where output files should be saved. Defaults to current working directory.
Examples
if (FALSE) {
fitvals <- generate_cfs(
calibration_csv = "data_parsed.csv",
subset_rows = TRUE, rows_to_keep = c("C","D"),
outfolder = "cfs_mCherry"
)
}