count snps across chromosome in window sizes

54 views
Skip to first unread message

Cristian Canales

unread,
Mar 9, 2023, 9:18:28 AM3/9/23
to dartR
Hello folks,

I have my data aligned to a genome reference and I'm looking for a function in dartR to count the number of genomic variants in an arbitrary window size in order to plot SNP density along chromosomes.
I noted that I can do this in the program bedtools however also there is no function con convert my dart object to this format.

Any idea how to do this? I’ll appreciate any comment that can help me.

Thanks in advance.

Cristian

Jose Luis Mijangos

unread,
Mar 14, 2023, 12:02:05 AM3/14/23
to dartR
Hi Cristian,

dartR doesn't have a function to plot SNP density along chromosomes, we will add it to our to-do list and should be available in next release of dartR hopefully in the next few weeks.

In the meantime, you can create an input file for bedtools using the code below.

# the system used by the BED format is zero-based for the coordinate start and
# one-based for the coordinate end. Thus, the nucleotide with the coordinate 1 in
# a genome will have a value of 0 in column 2 and a value of 1 in column 3.
# A thousand-base BED interval with the following start and end:
# chr7    0    1000
library(dartR)

t1 <- platypus.gl

t1 <- gl.filter.callrate(t1,threshold = 1)

# keeping just the loci that were mapped to chromosomes or contigs using
# BLAST alignment E-value
t1 <- gl.filter.locmetric(
  t1,
  metric = "AlnEvalue_Platypus_Chrom_NCBIv1",
  lower = min(t1$other$loc.metrics$AlnEvalue_Platypus_Chrom_NCBIv1),
  upper = 1e-20
)

#assigning chromosome and snp position
t1$chromosome <- as.factor(t1$other$loc.metrics$Chrom_Platypus_Chrom_NCBIv1)
t1$position <- t1$other$loc.metrics$ChromPos_Platypus_Chrom_NCBIv1
t1$other$loc.metrics[30:41,]
bed <- cbind(as.character(t1$chromosome), (t1$position - 1), t1$position)

# writing bed file
write.table(
  bed,
  file = "test.bed",
  col.names = FALSE,
  row.names = FALSE,
  quote = FALSE,
  sep = "\t"
)

Cheers,
Luis

Cristian Canales

unread,
Mar 14, 2023, 10:28:43 AM3/14/23
to da...@googlegroups.com
Thanks, Jose Luis for your reply and the code to resolve in the meantime my issue. I let you know if everything goes well with this code.
I'll be waiting for the next release of dartR.
 
My best,

Cristian




--
You received this message because you are subscribed to a topic in the Google Groups "dartR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dartr/Y0U5UDzusZo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/0b7d3323-a3ac-419d-8218-aa31fe12dbd7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages