for use with mASCI data- 2025 samples only

library(knitr)
library(readxl)
#detach(package:plyr)
library(dplyr)
library(ggplot2)
library(reshape2)
library(kableExtra)
library(ggh4x)
library(stringr)
library(seqinr)
library(palettetown)
library(phyloseq)
set.seed(100)

get sequencing runs

## [1] "done :)"

get taxonomy assignments

## [1] "done :)"

combine taxonomy assignments

## [1] "done :)"

combine sequencing runs at ASV/sequence level

## [1] "% of 5/6/26 ASV in 12/4/25: 14.9"
## [1] "% of 5/6/26 ASV in 7/15/26: 55.1"
## [1] "% of 12/4/25 ASV in 7/15/26: 29.3"
## [1] "total ASV of 3 runs: 4225"
## [1] "total sequences of 3 runs: 4428321"

get non-merged sequences

## [1] "# ASV shared between 3 runs: 95"
## [1] "# sequences shared between 3 runs: 1443305"
## [1] "% sequences shared between 3 runs: 32.59"

export

combo2.tax$all.cases<-ifelse(combo2.tax$sequence %in% combo2.tax.cc$sequence, 
                             "", "not_complete")
#sum(combo2.tax$all.cases=="not_complete") #check
combo2.tax<-combo2.tax[, !grepl("sequence3|seq_name3", colnames(combo2.tax))]
write.csv(combo2.tax, row.names = F, 
          "/Users/kylielanglois/SCCWRP/KL data - General/sequencing/data/mASCI_rcbL_2025_combo_nochim.csv")

combo2.tax.1<-combo2.tax[,!grepl("Taxon|seq|Cons|cases", colnames(combo2.tax)) ]
write.csv(combo2.tax.1, row.names = F, 
          "/Users/kylielanglois/SCCWRP/KL data - General/sequencing/data/mASCI_rcbL_2025_combo_nochim_table.csv")

vec1<- toupper(combo2.tax$sequence)
vec2<- combo2.tax$ASV
write.fasta(sequences= as.list(vec1), names = vec2,
            file.out = "/Users/kylielanglois/SCCWRP/KL data - General/sequencing/data/mASCI_rcbL_2025_combo_nochim_repset.csv")

combo2.tax.2<-combo2.tax[,grepl("Taxon|seq|Cons", colnames(combo2.tax)) ]
write.csv(combo2.tax.2, row.names = F, 
          "/Users/kylielanglois/SCCWRP/KL data - General/sequencing/data/mASCI_rcbL_2025_combo_nochim_tax.csv")