lncdr

Convenience functions for the LNCD. Includes db query, data processing, modeling, and visualizing

https://github.com/labneurocogdevel/lncdr

Science Score: 75.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
    Organization labneurocogdevel has institutional domain (lncd.pitt.edu)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.5%) to scientific vocabulary

Keywords

afni neuroimaging r
Last synced: 10 months ago · JSON representation ·

Repository

Convenience functions for the LNCD. Includes db query, data processing, modeling, and visualizing

Basic Info
  • Host: GitHub
  • Owner: LabNeuroCogDevel
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 3.94 MB
Statistics
  • Stars: 3
  • Watchers: 19
  • Forks: 1
  • Open Issues: 0
  • Releases: 2
Topics
afni neuroimaging r
Created almost 11 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Citation

readme.md

LNCDR

Convenience functions for the LNCD

Test_LNCDR

DOI

Install

Succinctly, you can install with the command R remotes::install_github('LabNeuroCogDevel/LNCDR')

In more detail: ```R

install the package that handles installing if we haven't already

if (!'remotes' %in% installed.packages()) install.packages('remotes')

if reinstalling, remove the old package from this workspace

detach("package:LNCDR", unload=TRUE)

(re)install from most recent online source

remotes::install_github('LabNeuroCogDevel/LNCDR')

load package

library(LNCDR) ```

Help

For help on all functions, in an R console, see ?LNCDR::tab

Functions

Stats

gam_growthrate

For better/more plotting facilities, see tidygam and tidymv (predict_gam and plot_smooths), gratia, and/or ggeffects. There's also a nice tutorial by Bart Larsen.

gam_growthrate_plot

R m <- gam(f1score ~ s(Ageatvisit) + s(visit) + s(id, bs="re"), data=d) ci <- gam_growthrate(m, 'Ageatvisit') gam_growthrate_plot(d, m, ci, 'Ageatvisit','f1score','id')

zscore zscorecols zscorewithinfactor

zscore dataframes

lmer_extract

get values (t, chisq, p) from a single variable in a model

Plotting

age_animate

gganimate for data frames with an age column.

```R d <- data.frame(age=seq(10,30, length.out=8), x=runif(8), y=runif(8)) p <- ageanimate(d, repsteps=16) + aes(x=x, y=y) + labs(title = 'Age: {frameage}')

gif <- p %>% lunaize %>% animate(fps=4, nframes=16, width = 480, height = 480) animsave("img/exampleanimate.gif", gif) ```

age_animate

waterfall_plot

Plot age at each visit for each participant (id and age column).

```R data.frame(id=rep(c(1:10),2), age=rep(c(11:20),each=2)+runif(20), sex=sample(rep(c('M','F'),5))) %>% waterfallplot() + aes(color=sex) + see::thememodern()

ggsave("img/waterfall_example.png",dpi=90, units='px', width=600, height=300) ```

waterfall plot

pubmed_search

For meta analysis, get a dataframe of pubmed search results (doi, title, authors, journal, year, abstract) ```R btcpapers <- pubmedsearch("Tervo-Clemmens[Author]", "tmp_xml/authsearch")

# journal title year abstract doi authors # Biologi… Early … 2018 Retrospective neuroimaging studies hav… 10.1… Tervo-C… # NeuroIm… Adoles… 2018 Given prior reports of adverse effects… 10.1… Tervo-C… # Frontie… Neural… 2017 Risk for substance use disorder (SUD) … 10.3… Tervo-C… # Annual … An int… 2015 "Brains systems undergo unique and spe… 10.1… Luna, B… # Journal… Explor… 2013 Comorbid depression and anxiety disord… 10.4… Boyd, R… ```

lunaize

A better alternative is probably cowplot::theme_cowplot() or see::theme_modern()

Apply Dr. Luna's style to a ggplot. See ?lunaize for usage.

lunastyle

Data Wrangling

save1D

Dataframe to 1D file:

Given a data frame with a block column and a specified onset column, generate a 1D file for use in afni's 3dDeconvolve.

date_match

Match behavioral visit to scan visit.

Given two dataframes, both with a column of near matching dates, find the best match between the two.

parseROItempcor

read ROI_TempCorr *.rac1.adj_pearson.txt outputs into per subject rows.

roicormat_wide

extract unique pairs from a correlation matrix into a single row.

db_query

use .pg_pass to make quick queries to central database.

col_ungroup

extract variable grouped columns into rows. DEPRICATED. see tidyr::pivot_longer and https://mgimond.github.io/ES218/Week03b.html ``` a.mean b.mean c.mean a.std b.std c.std 1 2 3 .6 .5 .4

TO

grp mean std a 1 .6 b 2 .5 c 3 .4

```

interactive_label_match

match labels from one string vector with another

uppsp_scoring

scores uppsp 59-item

Imaging

to_nii

write a nifti file from a voxelwise dataframe

vox_cor

Given a seed region (mask) and target region (mask), return voxelwise correlations from a 4d nifti.

R seed <- read_mask("striatum_mask.nii.gz") target <- read_mask("gm_mask.nii.gz") target <- target & ! seed allcors <- vox_cor("subj_ts.nii.gz",seed,target)

spectrum functions

afni spect1 R afni_save_spectrum(5, thres=2.68, posonly=T, lab="F")

spect2

You can also load a custom spectrum by right clicking Olay and saving the spectrum as a jpeg

getFromAfni custumnSpec

```R

custumn color scale

cv <- afni.spectrum(0:5,img='customspec.jpg') plotcolorspectrum(cv,'',side=1) ```

ijk functions

Convert ijk indexes between afni and oro MNI(LPI) data matrix.

afni_ijk

R x <- oro.nifti::readNIfTI('betas.nii.gz') dm <- dim(x) mx <- arrayind(which.max(d),dm) ijk.oro2afni(mx[1:3], dm )

Building the package and documentation

Build and test

make # see Makefile

Notes

Hilary Parker's package writeup was used as a template. Rscript -e "devtools::document(); setwd('..'); devtools::install('LNCDR')"

Tests follow Hadley Wickham's testthat description.

Adding functions

  1. create a new or edit an existing *.R file within R/.
    • make sure #' @export is above a function definition you want exported. See roxygen primer. You can got to any function using 3 colons: LNCDR:::function_without_export
    • Other functions (esp. R/ld8.R) are a good starting place.
  2. runmake
    • or, in an R console, run: devtools::document(); devtools::install('./')

Owner

  • Name: Laboratory of Neurocognitive Development
  • Login: LabNeuroCogDevel
  • Kind: organization
  • Location: Pittsburgh, PA

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Tervo-Clemmens"
  given-names: "Brenden"
  orcid: "https://orcid.org/0000-0002-9557-1126"
- family-names: "Foran"
  given-names: "William"
  orcid: "https://orcid.org/0000-0001-7491-9798"
title: "LNCDR"
version: 0.0.1
doi: 10.5281/zenodo.6470999
date-released: 2022-04-19
url: "https://github.com/LabNeuroCogDevel/LNCDR"

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Dependencies

.github/docker/action.yml actions
  • ../../Dockerfile * docker
.github/workflows/test_lncdr.yml actions
  • ./.github/docker * composite
  • actions/checkout v2 composite
DESCRIPTION cran
  • R >= 4.0 depends
  • dplyr >= 1.0.0 depends
  • DBI >= 1.1.0 imports
  • car >= 3.0 imports
  • ggplot2 >= 3.1.1 imports
  • gridExtra >= 2.3 imports
  • ini >= 0.3.1 imports
  • itsadug >= 2.3 imports
  • neuroCombat >= 1.0.5 imports
  • oro.nifti >= 0.9.1 imports
  • psych >= 2.0.12 imports
  • qualtRics >= 3.1.4 imports
  • reshape2 >= 1.4.4 imports
  • RPostgreSQL >= 0.6 suggests
  • XML >= 3.98 suggests
  • checkmate * suggests
  • devtools * suggests
  • easyPubMed >= 2.13 suggests
  • gganimate * suggests
  • testthat * suggests
  • viridis * suggests
Dockerfile docker
  • rocker/tidyverse latest build