1

I'm working on analyzing some fastq files in R for 16s work. I have a previous script from someone that has successfully done this before, but when I did:

path_1 <- "set to my WD"

then went to get a list of the files in the path using

list.files(path_1)

only 33 of the 204 are returned. However, when I do:

list.files(all.files=TRUE)

all of my files show. I'm not sure if I can go forward with the analysis or not. I know for the next steps it's not working. I go to sort them with the command below and only get 15 or 16 of them that show up as sorted.

Fs_1 <- sort(list.files(path_1, pattern="_R1_001.fastq.gz", full.names = TRUE))
Rs_1 <- sort(list.files(path_1, pattern= "_R2_001.fastq.gz", full.names = TRUE))

I'm wondering why all my files are not showing with list.files(path_1) because this seems to be affecting my downstream workflow. I'm hoping to get all 204 of my files to appear and be sorted correctly so I can continue with my analysis.

For example this was

# found:
CF10_S9_L001_R1_001.fastq.gz
CF10_S9_L001_R2_001.fastq.gz

# not found:
CF8_S7_L001_R1_001.fastq.gz
CF8_S7_L001_R2_001.fastq.gz
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
Laeanna
  • 11
  • 2
  • Please add an example of a few files in your directory that are successfully found and that are not successfully found. `pattern` uses regex for file name matching, and your pattern may need adjusting. – Gregor Thomas Jun 28 '23 at 20:36
  • I added a few examples. They appear identical to me – Laeanna Jun 28 '23 at 20:55
  • I see two differences between (a) `list.files(path_1)` and (b) `list.files(all.files=TRUE)`. In (a), you use the path specified in `path_1`, whereas in (b) you use the default: current working directory; and in (b) you say `all.files = TRUE` which according to the documentation includes "hidden files" that have names beginning with a `.`, but in (a) you don't. The files missed in your example don't have names starting with a `.`, therefore I don't think the `all.files = TRUE` is helping. This leads me to think that `path_1` points to a different directory than your working directory.... – Gregor Thomas Jun 28 '23 at 21:05
  • Run `getwd()` and see the directory that `list.files(all.files=TRUE)` is looking in. My guess is that it's different from the directory in `my_path`, and that while `my_path` has a few files, your `getwd()` working directory has all of them. – Gregor Thomas Jun 28 '23 at 21:07
  • Thats what confuses me. The working directory is the same place I set it with that path_1 code. – Laeanna Jun 28 '23 at 21:30

1 Answers1

0

I found out the folder was synced to icloud. Once I downloaded to my computer it worked.

Laeanna
  • 11
  • 2