Read in cortical bone data
read_cortical_csv.Rd
These are wrappers around readr::read_csv()
and readxl::read_excel()
to
read in and process cortical bone microCT data from two files: a twice1.csv
and a twice2.csv
file, or the Twice1
and Twice2
sheets of a data.xlsx
file. It uses a key
object to look up and add sex, genotype, and site
information.
Usage
read_cortical_csv(twice1_file, twice2_file, key, ...)
read_cortical_excel(
data_file,
key,
twice1_sheet = "Twice1",
twice2_sheet = "Twice2",
...
)
Arguments
- twice1_file
The file path to the
twice1.csv
file (forread_cortical_csv()
).- twice2_file
The file path to the
twice2.csv
file (forread_cortical_csv()
).- key
The
key
object containing sample information, as created by theread_key_csv()
orread_key_excel()
function.- ...
Additional arguments passed on to
readr::read_csv()
orreadxl::read_excel()
.- data_file
The path to the
data.xlsx
file (forread_cortical_excel()
).- twice1_sheet, twice2_sheet
For
read_cortical_excel()
, the sheets to read. Either strings (the name of the sheets), or integers (the positions of the sheets). Default to"Twice1"
and"Twice2"
.
Value
A tibble/data frame containing cortical bone data. For example:
| AS|Sex |Genotype | SampNo|Site | MeasNo| Ct.vBMD| Ct.Th| End.Circ| Peri.Circ| Ct.Po| Ct.Po.V|
|----:|:---|:--------|------:|:----|------:|--------:|-----:|--------:|---------:|-----:|-------:|
| 1365|M |Cre | 10778|Met | 31710| 937.049| 0.129| 5.533| 6.342| 0.41| 0.002|
| 1365|M |Cre | 10778|Dia | 31712| 1114.873| 0.220| 3.963| 5.343| 0.11| 0.001|
| 1366|F |Cre | 10779|Met | 31713| 1011.473| 0.183| 4.337| 5.485| 0.26| 0.001|
| 1366|F |Cre | 10779|Dia | 31715| 1133.066| 0.232| 3.250| 4.705| 0.10| 0.000|
| 1367|F |Cre;fl | 10780|Met | 31716| 994.868| 0.145| 4.892| 5.806| 0.37| 0.002|
| 1367|F |Cre;fl | 10780|Dia | 31718| 1137.300| 0.209| 3.514| 4.827| 0.14| 0.001|
Examples
gen_key <- read_key_csv(mctr_ex("example-gen-key.csv"))
#> Rows: 12 Columns: 7
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): Sex, Genotype
#> dbl (5): AS, SampNo, Spine, Met, Dia
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
gen_cort <- read_cortical_csv(mctr_ex("example-twice1.csv"),
mctr_ex("example-twice2.csv"),
gen_key)
#> Rows: 36 Columns: 75
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (44): SampName, MeasDate, ListDate, Filename, Site, Energy-I-Code, Contr...
#> dbl (26): SampNo, MeasNo, Integr.Time, Sigma, Support, Threshold, Unit, Data...
#> lgl (5): S-DOB, S-Remark, Meas-Rmk, RAW-Label, IMA-Label
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 36 Columns: 75
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (43): SampName, MeasDate, ListDate, Filename, Site, Energy-I-Code, Contr...
#> dbl (27): SampNo, MeasNo, Integr.Time, Sigma, Support, Threshold, Unit, Data...
#> lgl (5): S-DOB, S-Remark, Meas-Rmk, RAW-Label, IMA-Label
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
gen_cort <- read_cortical_excel(mctr_ex("example-genotype.xlsx"),
gen_key)