# Problems with Automatic Manifest Maker (Rlang)

**URL:** https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126
**Category:** Other Bioinformatics Tools
**Created:** [September 20, 2018, 12:09pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126 "2018-09-20T12:09:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 20, 2018, 12:09pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/1 "2018-09-20T12:09:06Z")

</div>

Hello! Loving the script!  
I think it would be worth a mention so the novices such as myself remember to make sure the script is being interpreted by R and not bash.  
Unfortunately I get this error when I try to run

(R-Env) qiime2@qiime2core2018-8:~/Desktop/MACE\_DEMUX\_FASTQs/barcode07$ ~/Taxonomy.R  
Error in `[<-.data.frame`(`*tmp*`, "direction", value = "forward") :  
replacement has 1 row, data has 0  
Calls: [\<- -\> [\<-.data.frame  
Execution halted

I've never done anything in R before so was hoping you could lend a hand to the meek!

Cheers!!

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 25, 2018, 1:29pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/2 "2018-09-25T13:29:29Z")

</div>

Hi all!  
please see [r - Tidyverse conflicts with automatic manifest maker - Stack Overflow](https://stackoverflow.com/questions/52496914/tidyverse-conflicts-with-automatic-manifest-maker/52498031?noredirect=1#comment91937434_52498031)  
for ammendments

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 25, 2018, 2:56pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/3 "2018-09-25T14:56:47Z")

</div>

here is the ammended script for anyone who is interested. make sure you have your data in a sub directory called "Data" and edit ~/Desktop/MACE\_DEMUX\_FASTQs/barcode11 to be your parent directory

#!/usr/bin/env Rscript  
library(tidyverse)

data\_path \<- paste("~/Desktop/MACE\_DEMUX\_FASTQs/barcode11", "Data", sep = "/")  
SamplesF \<- list.files(path = data\_path, pattern = "\*.R1.fastq.gz", all.files = FALSE,  
full.names = TRUE, recursive = FALSE,  
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

TabF \<- as.data.frame(SamplesF)

PathF \<- data.frame(lapply(TabF, function(TabF) {gsub("Data/", "$PWD/N/", TabF)}))  
PathF \<- data.frame(lapply(PathF, function(PathF) {gsub("fastq.gz", "fastq.gip", PathF)}))

names(PathF)[names(PathF)=="SamplesF"] \<- "absolute-filepath"

PathF['direction']='forward'

PathF['sample-id']= SamplesF

PathF \<- data.frame(lapply(PathF, function(PathF) {gsub("Data/", "sample-", PathF)}))  
PathF \<- data.frame(lapply(PathF, function(PathF) {gsub(".R1.fastq.gz", "", PathF)}))  
PathF \<- data.frame(lapply(PathF, function(PathF) {gsub("fastq.gip", "fastq.gz", PathF)}))  
PathF \<- data.frame(lapply(PathF, function(PathF) {gsub("/N/", "/Data/", PathF)}))

PathF \<- PathF[,c(3,1,2)]

SamplesR \<- list.files(path = data\_path, pattern = "\*.R2.fastq.gz", all.files = FALSE,  
full.names = TRUE, recursive = FALSE,  
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

TabR \<- as.data.frame(SamplesR)

PathR \<- data.frame(lapply(TabR, function(TabR) {gsub("Data/", "$PWD/N/", TabR)}))  
PathR \<- data.frame(lapply(PathR, function(PathR) {gsub("fastq.gz", "fastq.gip", PathR)}))

names(PathR)[names(PathR)=="SamplesR"] \<- "absolute-filepath"

PathR['direction']='reverse'

PathR['sample-id']= SamplesR

PathR \<- data.frame(lapply(PathR, function(PathR) {gsub("Data/", "sample-", PathR)}))  
PathR \<- data.frame(lapply(PathR, function(PathR) {gsub(".R2.fastq.gz", "", PathR)}))  
PathR \<- data.frame(lapply(PathR, function(PathR) {gsub("fastq.gip", "fastq.gz", PathR)}))  
PathR \<- data.frame(lapply(PathR, function(PathR) {gsub("/N/", "/Data/", PathR)}))

PathR \<- PathR[,c(3,1,2)]

Manifest \<- rbind(PathF, PathR)

names(Manifest)[names(Manifest)=="sample.id"] \<- "sample-id"

names(Manifest)[names(Manifest)=="absolute.filepath"] \<- "absolute-filepath"

write\_csv(Manifest, "Manifest.csv")

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 27, 2018, 3:24pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/4 "2018-09-27T15:24:58Z")

</div>

IMPORTANT!!!  
ALL OF THE "" and '' change format to curly types here! =O  
Please take care to change them back before use!

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 27, 2018, 3:25pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/5 "2018-09-27T15:25:22Z")

</div>

For use on single end reads please use this instead of the above (WARNING, still fresh off the press so is likely to have a few issues)

````auto
 #!/usr/bin/env Rscript
library(tidyverse)

data_path <- paste (setwd ("Data/"),"Data", sep = "/")
SamplesF <- list.files(path = data_path, pattern = "*.R1.fastq.gz", all.files = FALSE,
       full.names = TRUE, recursive = FALSE,
       ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

TabF <- as.data.frame(SamplesF)

PathF <- data.frame(lapply(TabF, function(TabF) {gsub("Data/", "$PWD/N/", TabF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub("fastq.gz", "fastq.gip", PathF)}))

names(PathF)[names(PathF)=="SamplesF"] <- "absolute-filepath" 

PathF['direction']='forward'

PathF['sample-id']= SamplesF

PathF <- data.frame(lapply(PathF, function(PathF) {gsub("Data/", "sample-", PathF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub(".R1.fastq.gz", "", PathF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub("fastq.gip", "fastq.gz", PathF)})) 
PathF <- data.frame(lapply(PathF, function(PathF) {gsub("/N/", "/Data/", PathF)})) 

PathF <- PathF[,c(3,1,2)]

Manifest <- rbind(PathF)

names(Manifest)[names(Manifest)=="sample.id"] <- "sample-id" 

names(Manifest)[names(Manifest)=="absolute.filepath"] <- "absolute-filepath" 

write_csv(Manifest, "Manifest.csv")

```
````

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [September 27, 2018, 3:58pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/6 "2018-09-27T15:58:32Z")

</div>

Hey there @mouldinator ---

Discourse (the platform this forum is built on) supports a wide variety of formatting options, including code formatting. Simply place your code in a triple-backtick code-fence like this:

````
```
my code...
```

````

You can also get syntax highlighting:

````
```bash
echo $PATH
```

````

which will render like this:

```bash
echo $PATH

```

Regarding the curly quotes - those might also be coming from the editor you are working with, but if not, the code fences will use programming quotes instead of prose quotes.

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 27, 2018, 4:00pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/7 "2018-09-27T16:00:25Z")

</div>

Thanks, will use that in the future =)  
cheers

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [September 27, 2018, 4:06pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/8 "2018-09-27T16:06:42Z")

</div>

Feel free to use it now --- you can actually edit your [existing](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/3) posts, that way you can remove your [warning about curlies](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/4).

The future is _now_! 🕶 🌛

---

<div class="post-metadata">

### Author: ![Micro\_Biologist](https://forum.qiime2.org/user_avatar/forum.qiime2.org/micro_biologist/32/4190_2.png) [@Micro\_Biologist](https://forum.qiime2.org/u/Micro_Biologist)
#### Post date: [September 28, 2018, 12:09pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/9 "2018-09-28T12:09:58Z")

</div>

Whilst I think it is a good idea to make the directory a variable to make it easier to change, I did say you'd need to change it...

---

<div class="post-metadata">

### Author: ![mouldinator](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@mouldinator](https://forum.qiime2.org/u/mouldinator)
#### Post date: [September 28, 2018, 3:00pm UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/10 "2018-09-28T15:00:29Z")

</div>

@ Micro\_Biologist hey there! Unfortunately didn't do a very good job; I keep getting the absolute filepath pasted onto the sequence ID in the manifest files and qiime tools cant Import it as it dosnt recognise the manifest file type

---

<div class="post-metadata">

### Author: ![Charlie](https://forum.qiime2.org/user_avatar/forum.qiime2.org/charlie/32/5671_2.png) [@Charlie](https://forum.qiime2.org/u/Charlie)
#### Post date: [September 4, 2019, 12:45am UTC](https://forum.qiime2.org/t/problems-with-automatic-manifest-maker-rlang/6126/11 "2019-09-04T00:45:13Z")

</div>

Hello, you may want to take a look at this plugin which generate metadata and manifest through folder structure : )  
[https://library.qiime2.org/plugins/qiime2-manifest-metadata-generator/23/](https://library.qiime2.org/plugins/qiime2-manifest-metadata-generator/23/)
