File system and project management

Pre-class activity for today:

Understanding file management

  • Start thinking in terms of nested hierarchies

Alternative visualization

# fs::dir_tree(path = "~", 1)

Alternative visualization

# fs::dir_tree("~/Desktop/gklab", 0)

Alternative visualization

# fs::dir_tree("~/Desktop/gklab/research", 0)

Exercise

Consider the following directory structure:

Home/
├── coursework
│   ├── course1
│   ├── course2
│   └── course3
└── teaching
    └── f25-repro-res
  • You are currently working within the directory ~/research/project1, but you realize it is time to review your notes for Course 2. What command can you use to navigate into the course2 directory?

Exercise

Consider the following directory structure:

Home/
├── coursework
│   ├── course1
│   ├── course2
│   └── course3
└── teaching
    └── f25-repro-res
  • You are currently working within the project1 directory, but your collaborator asks about a file related to your Project 3. Without changing directories, what command could you run to list all the files in the project3 directory?

Exercise

Consider the following directory structure:

Home/
├── coursework
│   ├── course1
│   ├── course2
│   └── course3
└── teaching
    └── f25-repro-res
  • You had written a script “cool-analysis.R” for your research Project 2 which you now realize is relevant for the Fall 2025 Reproducible Research course. Assuming you are currently in the Home directory, what command could you use to copy cool-analysis.R from the project2 directory into the f25-repro-res directory?

Exercise

Consider the following directory structure:

Home/
├── coursework
│   ├── course1
│   ├── course2
│   └── course3
└── teaching
    └── f25-repro-res
  • You got back 252 fastq sequence files from the first big sequencing run of your dissertation. Congrats! In your excitement, you downloaded and stored these under project3 even though they have to do with Project 1. From within the project1 directory, how could you move all 252 of these files over from project3?

Why are we starting the semester with file paths?

  • Essential for reading data into your analysis pipeline

  • Nearly all analysis scripts will begin with something like this:

my_data <- read.csv("/path/to/file.csv")

Why are we starting the semester with file paths?

  • In a reproducible analysis context, if you can’t read in the dataset, you probably will give up with the reproduction.

  • Many R scripts begin with something like this:

my_data <- read.csv("~/Desktop/gklab/research/psf-kadumane/data/biomass.csv")
  • You will not be able to run this script on your computer without mucking around with the paths!

Better project management within RStudio

Example of a better organized project

# fs::dir_tree("../../../research/reproducing-analyses/sedgwick-CWM-demography/", 1)

# cat(readLines("../../../research/reproducing-analyses/sedgwick-CWM-demography/complete-analysis.Rmd"), sep = "\n")