---
title: "Creating Hybrid Chromosomes"
---
```{r setup, echo=FALSE, message=FALSE}
source("../../common.R")
```
|chromosome|start|end|
|:---:|:---:|:---:|
|Pf3D7_11_v3|1918029|1933390|
|Pf3D7_13_v3|2792022|2807397|
```{bash, eval= F}
elucidator extractByName --names "Pf3D7_11_v3 | organism=Plasmodium_falciparum_3D7 | version=2015-06-18 | length=2038340 | SO=chromosome" --fasta /tank/data/plasmodium/genomes/pf/genomes/Pf3D7.fasta --out Pf3D7_11_v3.fasta --overWrite
elucidator extractByName --names "Pf3D7_13_v3 | organism=Plasmodium_falciparum_3D7 | version=2015-06-18 | length=2925236 | SO=chromosome" --fasta /tank/data/plasmodium/genomes/pf/genomes/Pf3D7.fasta --out Pf3D7_13_v3.fasta --overWrite
elucidator trimToLen --fasta Pf3D7_11_v3.fasta --length 1918029 --overWrite --out Pf3D7_11_v3_front.fasta
elucidator trimToLen --fasta Pf3D7_13_v3.fasta --length 2792022 --overWrite --out Pf3D7_13_v3_front.fasta
elucidator trimFront --fasta Pf3D7_11_v3.fasta --forwardBases 1918029 --overWrite --out Pf3D7_11_v3_end.fasta
elucidator trimFront --fasta Pf3D7_13_v3.fasta --forwardBases 2792022 --overWrite --out Pf3D7_13_v3_end.fasta
elucidator appendReads --fasta Pf3D7_11_v3_front.fasta --seq Pf3D7_13_v3_end.fasta --overWrite --out Pf3D7_11_v3__Pf3D7_13_v3.fasta
elucidator appendReads --fasta Pf3D7_13_v3_front.fasta --seq Pf3D7_11_v3_end.fasta --overWrite --out Pf3D7_13_v3__Pf3D7_11_v3.fasta
sed 's/ .*/__Pf3D7_11_v3/g' Pf3D7_13_v3__Pf3D7_11_v3.fasta > renamed_Pf3D7_13_v3__Pf3D7_11_v3.fasta
sed 's/ .*/__Pf3D7_13_v3/g' Pf3D7_11_v3__Pf3D7_13_v3.fasta > renamed_Pf3D7_11_v3__Pf3D7_13_v3.fasta
elucidator sortReads --fasta combined_Pf3D7.fasta --sortBy name --overWrite --out Pf3D7_plus_11-13_13-11_hybrid.fasta
elucidator extractByName --names Pf3D7_11_v3__Pf3D7_13_v3,"Pf3D7_13_v3 | organism=Plasmodium_falciparum_3D7 | version=2015-06-18 | length=2925236 | SO=chromosome" --fasta Pf3D7_plus_11-13_13-11_hybrid.fasta --out Pf3D7_pure_11-13_13-11_hybrid.fasta --overWrite --excluding
```
```{r}
shared_11_13_region = readr::read_tsv("../../../sharedBetween11_and_13/investigatingChrom11Chrom13/shared_11_13_region.bed", col_names = T)
shared_11_13_region_hybrid = shared_11_13_region %>%
mutate(`#chrom` = gsub("^Pf3D7_11_v3$", "Pf3D7_11_v3__Pf3D7_13_v3", `#chrom`))%>%
mutate(`#chrom` = gsub("^Pf3D7_13_v3$", "Pf3D7_13_v3__Pf3D7_11_v3", `#chrom`)) %>%
mutate(end = ifelse(`#chrom` == "Pf3D7_11_v3__Pf3D7_13_v3", start + 15375, end)) %>%
mutate(end = ifelse(`#chrom` == "Pf3D7_13_v3__Pf3D7_11_v3", start + 15361, end)) %>%
mutate(len = end - start)
write_tsv(shared_11_13_region_hybrid, "../../../sharedBetween11_and_13/investigatingChrom11Chrom13/shared_11_13_region_onHybrid.bed")
write_tsv(bind_rows(shared_11_13_region, shared_11_13_region_hybrid), "../../../sharedBetween11_and_13/investigatingChrom11Chrom13/combined_shared_11_13_region.bed", col_names = F)
write_tsv(
bind_rows(
shared_11_13_region %>%
filter("Pf3D7_11_v3" == `#chrom`),
shared_11_13_region_hybrid%>%
filter("Pf3D7_13_v3__Pf3D7_11_v3" == `#chrom`)
),
"../../../sharedBetween11_and_13/investigatingChrom11Chrom13/shared_11_13_region_onPureHybrid.bed"
)
```