PR2 version 4.14.0
Radiolaria from Miguel Sandin
1 Reference
- Pipeline PR2_rads_pipeline.pdf (link)
Comments * 67 sequences were not in GenBank at time of update. Will need to rerun the import script with the missing sequences.
2 Init
source('../PR2_init.R', echo=FALSE)
source('../PR2_read_google.R', echo=FALSE)
<- pr2 %>%
pr2_18S filter(gene == "18S_rRNA")
<- pr2_18S %>%
pr2_18S_removed filter(!is.na(removed_version))
3 Set up the files
= c("Radiolaria")
target_group = "division"
target_level
<- "Radiolaria Miguel"
dir_pr2_update
$editor <- "M. Sandin"
pr2.env
<- function(file_name){str_c(dir_pr2_update,"/", file_name)}
full_path
<- full_path("pr2_rads_updated.xlsx")
file_pr2_update_excel
# create the directory for taxonomy output
dir.create(full_path("taxo"))
4 Read the original data and reformat
4.1 Read the data
- Number of sequences = 4911
<- import(file_pr2_update_excel, sheet = "sequences", guess_max=200000, na=c("", "-"))
pr2_update
str_c("Number of sequences : ", nrow(pr2_update))
4.2 Add to PR2 missing sequences from Genbank
Run the script
script_genbank_xml.R
on serverRun second part
PR2-update-GenBank.R
Note: 67 sequences are not yet in GenBank….
<- filter(pr2_update, !(genbank_accession %in% pr2_18S$genbank_accession))
pr2_missing ::datatable(pr2_missing, caption = "Updated sequences that are not present in PR2 ")
DT
# Use this data frame to download new sequences and then restart from beginning
<- pr2_missing %>%
accessions pull(genbank_accession)
saveRDS(accessions, full_path("accessions_new.rds"))
export(pr2_missing, full_path("pr2_radiolaria_not_genbank.xlsx"))
4.3 Sequences not in Genbank are removed from update
Number of sequences in Genbank : 4845
<- pr2_update %>%
pr2_update filter(!(genbank_accession) %in% pr2_missing$genbank_accession)
str_c("Number of sequences in Genbank : ", nrow(pr2_update))
4.4 Compare with sequences in PR2
Sequences in target group in PR2: 4633
Sequences in target group in PR2 that need update: 4844
Updated sequences that are not active in PR2: 32 (sequences removed from PR2)
Sequences from target group that are not in the update: 9 (these sequences have been removed from PR2 because too many ambiguities)
Sequences duplicated: 0
chimera sequences: 343
filter(pr2_18S, !!as.symbol(target_level) %in% target_group) %>%
::datatable(caption = "Sequences of target group in pr2 ")
DT
filter(pr2_18S, (genbank_accession %in% pr2_update$genbank_accession)) %>%
::datatable(caption = "Sequences of PR2 that need update")
DT
filter(pr2_update, (genbank_accession %in% pr2_18S_removed$genbank_accession)) %>%
::datatable(caption = "Updated sequences that are not active in PR2")
DT
filter(pr2_update, !(genbank_accession %in% pr2_18S$genbank_accession))%>%
::datatable(caption = "Updated sequences that are not present in PR2 ")
DT
filter(pr2_18S, (!!as.symbol(target_level) %in% target_group) &
!(genbank_accession %in% pr2_update$genbank_accession)) %>%
::datatable(caption = "Sequences from target group in PR2 that are not in update")
DT
left_join(select(pr2_update, genbank_accession),
select(pr2_18S, genbank_accession, pr2_accession)) %>%
count(genbank_accession) %>%
filter(n > 1) %>%
::datatable(caption = "Sequences updated with 2 entries in PR2 (e.g. with and without introns) ")
DT
filter(pr2_update, !is.na(chimera)) %>%
::datatable(caption = "Chimera") DT
5 Taxonomy
5.1 Build and check
- The old taxonomy is removed and the new taxonomy replaces it…
<- pr2_update %>%
pr2_taxo_updated filter(is.na(chimera)) %>%
group_by_at(pr2.env$taxo_levels[[8]][4:8]) %>%
count()
pr2_taxo_check(pr2_taxo_updated, pr2.env$taxo_levels[[8]][4:8], full_path("taxo"))
<- pr2_taxo_updated %>%
pr2_taxo_updated rename_all(~ str_c(.,"_new" )) %>%
::rename(species = species_new) %>%
dplyrleft_join(pr2_taxo) %>%
rename_at(pr2.env$taxo_levels[[8]], ~ str_c(.,"_old" )) %>%
rename_all( ~ str_replace(.,"_new", "_8" )) %>%
::rename(species_8 = species_old) %>%
dplyrmutate(kingdom_8 = "Eukaryota",
supergroup_8 = "Rhizaria",
division_8 = "Radiolaria",
domain_9 = "Eukaryota",
supergroup_9 = "TSAR",
division_9 = "Rhizaria",
subdivision_9 = "Radiolaria",
class_9 = class_8,
order_9 = order_8,
family_9 = family_8,
genus_9 = genus_8,
species_9 = species_8,
taxo_edited_version = pr2.env$version,
taxo_edited_by = "M. Sendin")
export(pr2_taxo_updated, full_path("taxo/taxo_updated.xlsx"))
5.2 Find taxa in PR2 that are not included in the update - DO NOT APPLY
- The old taxonomy is removed
<- pr2_taxo %>%
pr2_taxo_not_updated filter(!!as.symbol(target_level) %in% target_group) %>%
filter(!(species %in% pr2_taxo_updated$species_8))
export(pr2_taxo_not_updated , full_path("taxo_not_updated.xlsx"))
6 Finalization
6.1 Sequences that need updating
<- pr2_update %>%
pr2_update_final select(genbank_accession, species, start, end, chimera, eukref_biotic_relationship) %>%
::rename(species_new = species,
dplyrstart_new = start,
end_new = end) %>%
left_join(select(pr2_main, pr2_accession, genbank_accession, species, start, end, removed_version, edited_remark))
6.2 Sequences with different start or end
- 9 sequences have been reloaded into PR2 using the Genbank script.
- These sequences had been initially uploaded with Silva which had imperfect trimming of the end.
<- pr2_update_final %>%
pr2_sequence_to_update filter((start != start_new)|(end != end_new))
%>%
pr2_sequence_to_update ::datatable(caption = "Actual sequence and pr2_accession needs to be updated ") DT
6.3 pr2_main: Sequences without species name or with different species
- Number of updated sequences with prior taxonomy: 4399
- Number of updated sequences without prior taxonomy 220
<- pr2_update_final %>%
pr2_main_updated filter((species != species_new)|is.na(species) |!is.na(chimera))
%>%
pr2_main_updated ::datatable(caption = "Actual sequence and pr2_accession needs to be updated ")
DT
::glue("Number of updated sequences with prior taxonomy: {nrow(filter(pr2_main_updated, !is.na(species)))}")
glue::glue("Number of updated sequences without prior taxonomy {nrow(filter(pr2_main_updated, is.na(species)))}")
glue
<- pr2_main_updated %>%
pr2_main_updated select (genbank_accession,
species_8 = species_new,
species_9 = species_new,
removed_version,
edited_remark,%>%
chimera) mutate(edited_version = pr2.env$version,
edited_by = pr2.env$editor,
chimera = case_when(!is.na(chimera) ~ 1),
chimera_remark = case_when(!is.na(chimera) ~ "chimera detected by M. Sandin"),
removed_version = case_when(!is.na(chimera) ~ pr2.env$version,
TRUE ~ removed_version ))
6.3.1 pr2_metaddata
<- pr2_update_final %>%
pr2_metadata_updated select(genbank_accession, eukref_biotic_relationship) %>%
filter(!is.na(eukref_biotic_relationship))
7 Save everything to an Excel file
<- full_path("pr2_update_tables.xlsx")
file_pr2_imports <- list("pr2_main_updated" = pr2_main_updated,
onglets "pr2_metadata_updated" = pr2_metadata_updated,
"pr2_taxo_updated" = pr2_taxo_updated
)export(onglets, file_pr2_imports)