As Olly said, it is not advisable to merge two datasets with a different number of loci and different individuals, so the reanalysis of the two datasets from DArT is the safest option. This issue has been discussed previously in the forum, see:
Having said that, please find below some code of how to do the merging.
This would work assuming that DArT assigned the same loci names to all
the jobs of the same species.
I asked DArT bioinformaticians about loci names in different jobs from the same species, they said:
"The
SNP names which contain ID numbers less than 100,000,000 would be the
same between reports in general, however, in it also depends on whether
or not the 2 species have been assayed under the same organism
designation.
I would definitely recommend to request a co-analysis rather than try to combine the results."
Another potential source of bias would be that the reference allele is used in the names of the loci. The reference allele is based on the allele with higher frequency. This means that the reference allele could be different in different populations.
If you have a reference genome, one possible solution would be to map the trimmed sequences in both datasets using the function gl.blast.
library(dartR)
# test dataset
df_test <- gl.filter.callrate(df_test,threshold = 1)
df_test <- gl.filter.monomorphs(df_test)
#test dataset 1
test <- gl.keep.ind(df_test,ind.list = indNames(df_test)[1:5])
test <- gl.keep.loc(test, loc.list = locNames(test)[1:6])
#test dataset 2
test_2 <- gl.keep.ind(df_test,ind.list = indNames(df_test)[6:10])
test_2 <- gl.keep.loc(test_2, loc.list = locNames(test_2)[6:11])
# finding loci in common
common_loc_test <- locNames(test)[locNames(test) %in% locNames(test_2)]
common_loc_test_2 <- locNames(test_2)[locNames(test_2) %in% locNames(test)]
# keeping only loci in common
test <- gl.keep.loc(test,loc.list = common_loc_test)
test_2 <- gl.keep.loc(test_2,loc.list = common_loc_test_2)
# ordering loci
test <- test[,order(locNames(test))]
test_2 <- test_2[,order(locNames(test_2))]
# testing that loci names are equal and in the same order in both datasets. The result of the below command should be 0
sum(locNames(test)!=locNames(test_2))
#merging datasets
merge_gl <- rbind.genlight(test,test_2)
# running compliance function
merge_gl <- gl.compliance.check(merge_gl)
# recalculating metrics
merge_gl <- gl.recalc.metrics(merge_gl)