Informations on SNP Marker, Chromosome name, and SNP positions

32 views
Skip to first unread message

Jean Rodrigue Sangaré

unread,
Jul 10, 2025, 3:58:52 AMJul 10
to dartR

After completing SNP filtering, how can I obtain the names of retained markers, their corresponding chromosomes, and their positions on those chromosomes to construct a physical map?

Thanks

Jose Luis Mijangos

unread,
Jul 10, 2025, 9:19:04 AMJul 10
to dartR
Hi Jean,

Check the code below if it's useful.

Cheers,
Luis 

# Install the development version of dartR.base from GitHub
# (only needs to be run once, or whenever you want to update)
devtools::install_github("green-striped-gecko/dartR.base")

# Load the dartRverse package (which includes dartR.base)
library(dartRverse)

# Specify the path to your reference genome FASTA file
RefGenome <- "GCF_004115215.2_mOrnAna1.pri.v4_genomic.fna"

# Load your input genlight object (here using the built-in platypus.gl dataset)
t1 <- platypus.gl

# Perform BLAST of each locus in t1 against the reference genome
# This annotates each locus with alignment metrics in t2$other$loc.metrics
t2 <- gl.blast(t1, ref_genome = RefGenome)

# Extract the chromosome accession (sacc) from the BLAST results
# and store it as a factor in a new column ‘chromosome’
t2$chromosome <- as.factor(t2$other$loc.metrics$sacc)

# Compute the absolute SNP position by adding the BLAST start coordinate (sstart)
# to the original relative position in the locus object
t2$position <- t2$other$loc.metrics$sstart + t2$position

# Inspect the names (IDs) of the markers
locNames(t2)

# Inspect the chromosome assignments
t2$chromosome

# Inspect the computed SNP positions
t2$position

# Combine marker names, chromosome, and position into a single data frame
all_info <- data.frame(
  LocNames = locNames(t2),
  Chr      = as.character(t2$chromosome),
  Pos      = t2$position
)

# Write the combined SNP information to a CSV file
# (set row.names = FALSE to avoid writing an extra column)
write.csv(all_info, "all_info.csv", row.names = FALSE)

# Create a SNP density plot using dartR.base’s internal plotting function
# - bin.size: window size in base pairs (1 Mb here)
# - min.snps: only plot bins with at least this many SNPs
# - min.length: minimum chromosome length to include
# - color.palette: function to generate colors (using viridis here)
# - chr.info: show chromosome information
# - plot.title: title of the plot
p1 <- dartR.base:::gl.plot.snp.density(
  x             = t2,
  bin.size      = 1e+06,
  min.snps      = 50,
  min.length    = 1e+06,
  color.palette = viridis::viridis,
  chr.info      = TRUE,
  plot.title    = "SNP density"
)

# Save the SNP density plot to a PDF file
# - width/height: dimensions in inches
ggsave(
  filename = "SNP_density.pdf",
  plot     = p1,
  width    = 8,
  height   = 6,
  units    = "in"
)

Jean Rodrigue Sangaré

unread,
Jul 11, 2025, 6:23:55 AMJul 11
to dartR

Thank you, Luis. Could you please provide more details about my reference genome FASTA file and its path? In the metadata DarT sent me, there is a file named 'metadata' that mentions the reference genome is Rice_RGAP_v7. Here is the code I used:

library(dartRverse)

> RefGenome <- "C:/Users/JEAN/Documents/AMOVA" > 
RefGenome <-"Rice_RGAP_v7" > 
t1 <- readRDS("glmg.Rdata") > 
t2 <- gl.blast(t1, ref_genome = RefGenome)
Starting gl.blast 
 Error in gl.blast(t1, ref_genome = RefGenome) :
 Fatal Error: TrimmedSequence column is required!.

Jose Luis Mijangos

unread,
Jul 13, 2025, 8:28:28 PMJul 13
to dartR
Hi Jean,

If you asked DArT to map your SNPs to a reference genome, the chromosome information should be in the slot other$loc.metrics and the field should start with the word "Chrom", for example in the platypus dataset is here:

platypus.gl$other$loc.metrics$Chrom_Platypus_Chrom_NCBIv1

Similarly, your SNP position should be in the slot other$loc.metrics and the field should start with the word "ChromPos", in the platypus dataset is here:

platypus.gl$other$loc.metrics$ChromPos_Platypus_Chrom_NCBIv1

Cheers,
Luis 

Reply all
Reply to author
Forward
0 new messages