Jesse Moriarty Erhard
Jesse Moriarty Erhard

@vandalibm

21 Tweets 53 reads May 27, 2022
Advanced genetics part 1 ๐Ÿงต
In this thread we will look at how to use qpAdm in R. I compiled the code from two forums removing some of their issues. You can find them here:
eupedia.com
theapricity.com
First you need to download R. You can do that here:
cran.r-project.org
Now you need to dowload and install Rstudio. You can get that here:
rstudio.com
Next up you need to download the data. You need to download all the 1240K+HO files. You can do that here:
reich.hms.harvard.edu
Next up you need to create an excel file. I recommend you doing this in your downloads folder because the code that I am sharing is linking to that file. I also recommend calling the file "a". Leave it empty and close it.
Now open Rstudio. Go to the top left corner File -> New File. Now go to "save as". Save your project with any name you want and in any location you want. I called mine qpAdm.
Now we can get to coding. You need to install some packages. You can do that by running each line (top right corner) or by pressing ctrl + shift + enter.
You can get the code for installing packages here:
pastebin.com
You only need to install packages once. After that you can just use the following code (so remove some lines of code. I already did that for you). You can get the code (including the code for installing the packages) here:
pastebin.com
Line 8 (left) contains the "source" populations we will be using to see what our "target" (line 10) consists of.
You will need to change line 13, 16 and 17. As you can see my code refers to a file saying "Jesse". Line 13 refers to where you data is saved. Copy that and change that part between " ". Line 16 and 17 refer to the excel file. We named it "a" so only change the location
R doesn't work with "\" you need to use "/". The same way I used in line 13, 16 and 17. Those are the only things you need to adjust. Besides that you can see in line 13 the version from Reich's lab mentioned. Updates in the future you need to download again and change the line
Now you can run the entire code by pressing ctrl + shift + enter or running the code line by line. You should get something like this if you kept the same "target" and "source" populations. These are all for "Mari" left side shows p-value. A p-value higher than 0.05 is needed.
Now you can play with different populations. You can find the populations needed in the IND file. Open it in notepad (right click, choose open with then notepad).
qpAdm works with f4 statistics which is not something I'll discuss in this thread. The eupedia link I gave links to an anthrogenica post that discusses it briefly. But what you should note from this is that sometimes you might get errors if you don't pick good source populations
This is also why it is better to leave line 9 alone unless you know what you are doing.
Another thing you need to note is line 19. If you change line 8 change line 19 too for the necessary abbreviations you can yourself choose.
[END]
The basic series can be found here.

Loading suggestions...