Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 2.64 KB

readme.org

File metadata and controls

66 lines (48 loc) · 2.64 KB

MRSI PFC R

Original git repo for GABA vs Glu paper. Now also hosting general GAM adjusted MRSI for the PFC slice (adjust_all.R).

Located on rhea:/Volumes/Hera/Projects/7TBrainMech/scripts/mri/MRSI_roi/gam_adjust. Depends on 13MP20200207_LCMv2fixidx.csv created upstream. Used by /Volumes/Hera/Projects/7TBrainMech/scripts/Makefile to build merge7T.csv

Outputs

ls -tlrc out

Gotchas

  • thresholding value( abs(z)<3 ) and grouping (bilateral per metabolite) may not be ideal
  • general bugs from integrating (but see `test_*R` files)

Files

  • Makefile tries to list what scripts make what files and annotate their dependencies
  • mrsi_funcs.R has functions to clean, add columns (invage, age2, dateNumeric), and reshape from wide to long (useful for plotting and summarise over metabolite and region) – though the output files should have the output of those, so hopefully only useful for posterity
  • adjust_all.R runs per bilateral region+metabolite gam residual adjustment, but only for a few metabolites. But it’s hopefully easy to extend
mets_keep <- c("GABA","Glu","Gln","Cho","Glc", "MM20")

Make

Makefile attempts to record provenance of outputs.

run make to update only the outputs that are out of date.

Wide to Long

mrsi_funcs.R defines longer_met_CrSD() which reshape the wide (many columns) per-metabolite .Cr and .SD columns into a longer (more rows) dataframe with repeating samples: a row for each metabolite. New columns are 'met', 'Cr', and 'SD' replace the original columns GABA.Cr, GABA.SD, Glu.Cr, ....

Long format data is easier to plot and group_by/summarize (or in non-tidyverse speak map + reduce)

Thresholding

Per region per metabolite abs(zscore) threshold of 3 yields. (20230531 – TODO: confirm best strategy) imgs/thresholding_cnt_met_region.png

GAM adjustment

see adjust_all.R and visualize.R

imgs/gam_adjusted_Vs_Cr.png

Testing

./test_mrsi_funcs.R and ./test_res_with_age.R exercises some functions

invisible(lapply(Sys.glob("test_*R"),testthat::test_file) )

Merge 7T

out/gamadj_wide.csv is added to merge7T.csv many directories up from here (20230531). External measures (e.g. rest framewise displacement) are not included in this output because they are expected to be merged from the original source there.