sort by chromosome, position, individuals in DARTR OBJECT

19 views
Skip to first unread message

Cristian Canales

unread,
Feb 14, 2023, 7:05:28 PM2/14/23
to dartR

Dear friends,

I have my DARTR OBJECT dataset that was aligned to a reference genome. I would like to sort this DARTR OBJECT by chromosome and then by position within each chromosome to have an ordered dataset. Is there a function to do this?

On the other hand, I would like to sort my individuals in an arbitrary way (females and then males). Is there a function to do this in my DartSeq object?

Thank you in advance

Jose Luis Mijangos

unread,
Feb 14, 2023, 11:19:09 PM2/14/23
to dartR
Hi,

Creating a function in dartR to do the ordering is a nice idea.

We'll work on it and get it ready for the next release.

In the meanwhile, you might use the following code:

library(dartR)
# test dataset
t1 <- platypus.gl
# converting a genlight object into a dartR object
class(t1) <- "dartR"
# assigning chromosome and position information
t1$chromosome <- as.factor(t1$other$loc.metrics$Chrom_Platypus_Chrom_NCBIv1)
t1$position <- t1$other$loc.metrics$ChromPos_Platypus_Chrom_NCBIv1
# ordering loci by chromosome and position
# loci are in columns
t1 <- t1[,order(t1$chromosome,t1$position)]
# ordering individuals by sex
# individuals are in rows
t1 <- t1[order(t1$other$ind.metrics$Sex),]

Cheers,
Luis

Cristian Canales

unread,
Feb 15, 2023, 9:19:07 AM2/15/23
to dartR
Gracias Luis.
I look forward to the next release with all the new functions.
thanks for the code!
cca
Reply all
Reply to author
Forward
0 new messages