---
title: "full alignment (hisat)"
author: "Steven Roberts"
date: "2024-04-16"
output: html_document
---


```{bash}
find /home/shared/8TB_HDD_02/mewing0/clamgonads-macsamples/data/raw/*gz \
| xargs basename -s _R1_001.fastq.gz | xargs -I{} \
/home/shared/hisat2-2.2.1/hisat2 \
-x /home/shared/8TB_HDD_02/mewing0/clamgonads-macsamples/output/hisat/GCF_026571515.1_index \
-p 20 \
-1 /home/shared/8TB_HDD_02/mewing0/clamgonads-macsamples/data/raw/{}_R1_001.fastq.gz \
-2 /home/shared/8TB_HDD_02/mewing0/clamgonads-macsamples/data/raw/{}_R2_001.fastq.gz \
-S ../output/{}.sam
```


#convert sam to bam 


```{bash}
for file in ../output/*sam; do
    base=$(basename "$file" .sam)
    /home/shared/samtools-1.12/samtools view -@ 40 -bS "$file" | \
    /home/shared/samtools-1.12/samtools sort -@ 40 \
    -o ../output/"$base".bam
done
```

# missed 193 in the SR sam to bam conversion, adding in now
```{bash}

/home/shared/samtools-1.12/samtools view -@ 20 -bS ../output/hisat/hisat_out/M-C-193.sam | \
/home/shared/samtools-1.12/samtools sort -@ 20 -o ../output/hisat_bam/M-C-193.bam

```


# featurecounts

```{r}
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("Rsubread")
```

```{r}
library(Rsubread) 

```

```{r}

# this chunk doesnt wokr
featureCounts(files="../output/hisat_bam/", isPairedEnd=TRUE, nthreads=20)

```

## featurecounts command
```{bash}
/home/shared/subread-2.0.5-Linux-x86_64/bin/featureCounts \
-p --countReadPairs \
--primary \
-B \
-T 20 \
-C \
-O \
-t exon \
-g gene_id \
-a ../data/genomic.gtf \
-o ../output/featurecounts_gene \
../output/hisat_bam/*bam
```


