View source: R/convert_units.R
convert_units | R Documentation |
This function is designed to accept input units, output units, and the molecular weight (MW) of a substance of interest to then use a table lookup to return a scaling factor that can be readily applied for the intended conversion. It can also take chemical identifiers in the place of a specified molecular weight value to retrieve that value for its own use.
convert_units( input.units = NULL, output.units = NULL, MW = NULL, vol = NULL, chem.cas = NULL, chem.name = NULL, dtxsid = NULL, parameters = NULL, temp = 25, state = "liquid" )
input.units |
Assigned input units of interest |
output.units |
Desired output units |
MW |
Molecular weight of substance of interest in g/mole |
vol |
Volume for the target tissue of interest in liters (L). NOTE: Volume should not be in units of per BW, i.e. "kg". |
chem.cas |
Either the chemical name, CAS number, or the parameters must be specified. |
chem.name |
Either the chemical name, CAS number, or the parameters must be specified. |
dtxsid |
EPA's DSSTox Structure ID (http://comptox.epa.gov/dashboard) the chemical must be identified by either CAS, name, or DTXSIDs |
parameters |
A set of model parameters, especially a set that includes MW (molecular weight) for our conversions |
temp |
Temperature for conversions (default = 25 degreees C) |
state |
Chemical state (gas or default liquid) |
If input or output units not contained in the table are queried, it gives a corresponding error message. It gives a warning message about the handling of 'ppmv,' as the function is only set up to convert between ppmv and mass-based units (like mg/m3 or umol/L) in the context of ideal gases.
convert_units is not directly configured to accept and convert units based
on BW, like mg/kg. For this purpose, see scale_dosing
.
The function supports a limited set of most relevant units across toxicological models, currently including umol, uM, mg, mg/L, mg/m3 or umol/L), and in the context of gases assumed to be ideal, ppmv.
Andersen and Clewell's Rules of PBPK Modeling:
1Check Your Units
2Check Your Units
3Check Mass Balance
Mark Sfeir, John Wambaugh, and Sarah E. Davidson
# MW BPA is 228.29 g/mol # 1 mg/L -> 1/228.29*1000 = 4.38 uM convert_units("mg/L","uM",chem.cas="80-05-7") # MW Diclofenac is 296.148 g/mol # 1 uM -> 296.148/1000 = 0.296 convert_units("uM","mg/L",chem.name="diclofenac") convert_units("uM","ppmv",chem.name="styrene") # Compare with https://www3.epa.gov/ceampubl/learn2model/part-two/onsite/ia_unit_conversion.html # 1 ug/L Toluene -> 0.263 ppmv convert_units("ug/L","ppmv",chem.name="toluene") # 1 pppmv Toluene, 0.0038 mg/L convert_units("ppmv","mg/L",chem.name="toluene") MW_pyrene <- get_physchem_param(param='MW', chem.name='pyrene') conversion_factor <- convert_units(input.units='mg/L', output.units ='uM', MW=MW_pyrene)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.