Skip to content

Taking a Subset of Subjects in Your Distance Matrix

Zarrar Shehzad edited this page Mar 18, 2015 · 2 revisions

After running connectir_subdist.R comparing distances in connectivity maps between N subjects for V voxels, you may want to only examine a subset of those subjects (e.g., half of them) for a later MDMR using connectir_mdmr.R. Below, gives a sample run of the script connectir_filter_subdist.R that allows you this flexibility. The script will take a given subset of subjects and create a new copy of the distance matrices (at every voxel) including only the distances between the desired subset of subjects.

connectir_filter_subdist.R \
    -i /path/to/my_subdist_dir/subdist.desc \
    -m 04_subjects_matched.csv \
    --expr "group != 'ADHD-I'" \
    --forks 1 \
    --threads 12 \
    --memlimit 12 \
    ${sdir}/tdc_adhdc

I highlight some arguments/options below:

  • The -i option indicates the path to your subject distances found in the output folder when running `connectir_subdist.R.
  • The -m option specifies some csv file where each line in the file is a subject/scan that corresponds to the order of the subjects/scans when running connectir_subdist.R.
  • The --expr option is used in tandem with -m. It specifies some logical statement for specifying a subset of subjects. Here I am selecting any subject that isn't part of the group 'ADHD-I'. The group variable here corresponds to a column in the -m 04_subjects_matched.csv file. You can apply this expression to any column in your -m file to get some subset of the subjects.
  • Feel free to edit --forks, --threads, and --memlimit to suit your own setup.
  • The final argument is the output prefix. In this case, you might have ${sdir}/tdc_adhdc_subdist.desc as one of your outputs. Note: when you later run connectir_mdmr.R make sure to point to this new subject distances with the -i option.

You don't need to use the -m and --expr options for selecting the subset of subjects. You can also use the --whichsubs option. This should be a file that contains the indices of subjects (from those given to connectir_subdist.R) that you would like to select and take as a subset for a new subject distance matrices.

Please also check out the connectir_filter_subdist.R help for more information.

Clone this wiki locally