Skip to content

Runtime error in MAGScot.R when clustering solutions use identical naming syntax. #4

@cerebis

Description

@cerebis

An error occurs in MAGScot.R when the bin to contig file has more than one solution set and the naming syntax for the clusters is identical.

Although this scenario sounds far-fetched, it can occur if you supply different solutions from the same tool. It does not matter if the "Binner" (set names) are unique per solution.

The reported error is:

Error in UseMethod("tbl_vars") :
  no applicable method for 'tbl_vars' applied to an object of class "NULL"

And happens somewhere within:

MAGScoT/MAGScoT.R

Lines 130 to 140 in 0b7b6d1

binmatch=sapply(seq_along(merge_cand), function(thisbin_id){
cat("Processing candidate bin ",thisbin_id, " of ", length(merge_cand),"\r")
thisbin = merge_cand[thisbin_id]
thisbin_contigs = contig_to_bin_bisco_it %>% filter(bin == thisbin, contig %in% gene_to_contig$contig) %>% pull(contig)
thisbin_genes = gene_to_contig %>% filter(contig %in% thisbin_contigs)
if(it>1){thisbin_blacklist = bisco_out %>% filter(bin==thisbin) %>% select(bin_a, bin_b) %>% unlist %>% as.vector()}else{thisbin_blacklist=c()}
return(contig_to_bin %>% filter(contig %in% thisbin_genes$contig) %>% left_join(thisbin_genes, by="contig") %>%
distinct_at(.vars=c("bin","gene"), .keep_all=T) %>% group_by(bin) %>% summarize(shared_markers=n()) %>%
mutate(shared_markers_rel = shared_markers/length(unique(thisbin_genes$gene))) %>% filter(bin != thisbin, !bin %in% thisbin_blacklist, shared_markers_rel >= min_sharing) %>%
mutate(seed=thisbin, bin_a=ifelse(seed>bin, seed, bin), bin_b=ifelse(seed>bin, bin, seed)) %>% select(seed, bin_a, bin_b, shared_markers, shared_markers_rel))
}, simplify=F)

The error was resolved when the cluster names for one solution were made distinct by adding a single character to each cluster name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions