# edit this line to source in the correct SireModel_WorkingCopy.R script source('/SireModel_WorkingCopy.R', chdir = TRUE) setwd('~/Desktop') # edit this line to be the working directory containing this script and containing a subdrectory called NemoData which contains all 1,000 relicate nemo simulations of the 15 population island model # below, each nemo replicate will be looped through during the analysis by pllacing them in this vector all.files <- c( "NemoData/QstTest_160_0001.dat", "NemoData/QstTest_160_0002.dat", "NemoData/QstTest_160_0003.dat", "NemoData/QstTest_160_0004.dat", "NemoData/QstTest_160_0005.dat", "NemoData/QstTest_160_0006.dat", "NemoData/QstTest_160_0007.dat", "NemoData/QstTest_160_0008.dat", "NemoData/QstTest_160_0009.dat", "NemoData/QstTest_160_0010.dat", "NemoData/QstTest_160_0011.dat", "NemoData/QstTest_160_0012.dat", "NemoData/QstTest_160_0013.dat", "NemoData/QstTest_160_0014.dat", "NemoData/QstTest_160_0015.dat", "NemoData/QstTest_160_0016.dat", "NemoData/QstTest_160_0017.dat", "NemoData/QstTest_160_0018.dat", "NemoData/QstTest_160_0019.dat", "NemoData/QstTest_160_0020.dat", "NemoData/QstTest_160_0021.dat", "NemoData/QstTest_160_0022.dat", "NemoData/QstTest_160_0023.dat", "NemoData/QstTest_160_0024.dat", "NemoData/QstTest_160_0025.dat", "NemoData/QstTest_160_0026.dat", "NemoData/QstTest_160_0027.dat", "NemoData/QstTest_160_0028.dat", "NemoData/QstTest_160_0029.dat", "NemoData/QstTest_160_0030.dat", "NemoData/QstTest_160_0031.dat", "NemoData/QstTest_160_0032.dat", "NemoData/QstTest_160_0033.dat", "NemoData/QstTest_160_0034.dat", "NemoData/QstTest_160_0035.dat", "NemoData/QstTest_160_0036.dat", "NemoData/QstTest_160_0037.dat", "NemoData/QstTest_160_0038.dat", "NemoData/QstTest_160_0039.dat", "NemoData/QstTest_160_0040.dat", "NemoData/QstTest_160_0041.dat", "NemoData/QstTest_160_0042.dat", "NemoData/QstTest_160_0043.dat", "NemoData/QstTest_160_0044.dat", "NemoData/QstTest_160_0045.dat", "NemoData/QstTest_160_0046.dat", "NemoData/QstTest_160_0047.dat", "NemoData/QstTest_160_0048.dat", "NemoData/QstTest_160_0049.dat", "NemoData/QstTest_160_0050.dat", "NemoData/QstTest_160_0051.dat", "NemoData/QstTest_160_0052.dat", "NemoData/QstTest_160_0053.dat", "NemoData/QstTest_160_0054.dat", "NemoData/QstTest_160_0055.dat", "NemoData/QstTest_160_0056.dat", "NemoData/QstTest_160_0057.dat", "NemoData/QstTest_160_0058.dat", "NemoData/QstTest_160_0059.dat", "NemoData/QstTest_160_0060.dat", "NemoData/QstTest_160_0061.dat", "NemoData/QstTest_160_0062.dat", "NemoData/QstTest_160_0063.dat", "NemoData/QstTest_160_0064.dat", "NemoData/QstTest_160_0065.dat", "NemoData/QstTest_160_0066.dat", "NemoData/QstTest_160_0067.dat", "NemoData/QstTest_160_0068.dat", "NemoData/QstTest_160_0069.dat", "NemoData/QstTest_160_0070.dat", "NemoData/QstTest_160_0071.dat", "NemoData/QstTest_160_0072.dat", "NemoData/QstTest_160_0073.dat", "NemoData/QstTest_160_0074.dat", "NemoData/QstTest_160_0075.dat", "NemoData/QstTest_160_0076.dat", "NemoData/QstTest_160_0077.dat", "NemoData/QstTest_160_0078.dat", "NemoData/QstTest_160_0079.dat", "NemoData/QstTest_160_0080.dat", "NemoData/QstTest_160_0081.dat", "NemoData/QstTest_160_0082.dat", "NemoData/QstTest_160_0083.dat", "NemoData/QstTest_160_0084.dat", "NemoData/QstTest_160_0085.dat", "NemoData/QstTest_160_0086.dat", "NemoData/QstTest_160_0087.dat", "NemoData/QstTest_160_0088.dat", "NemoData/QstTest_160_0089.dat", "NemoData/QstTest_160_0090.dat", "NemoData/QstTest_160_0091.dat", "NemoData/QstTest_160_0092.dat", "NemoData/QstTest_160_0093.dat", "NemoData/QstTest_160_0094.dat", "NemoData/QstTest_160_0095.dat", "NemoData/QstTest_160_0096.dat", "NemoData/QstTest_160_0097.dat", "NemoData/QstTest_160_0098.dat", "NemoData/QstTest_160_0099.dat", "NemoData/QstTest_160_0100.dat", "NemoData/QstTest_160_0101.dat", "NemoData/QstTest_160_0102.dat", "NemoData/QstTest_160_0103.dat", "NemoData/QstTest_160_0104.dat", "NemoData/QstTest_160_0105.dat", "NemoData/QstTest_160_0106.dat", "NemoData/QstTest_160_0107.dat", "NemoData/QstTest_160_0108.dat", "NemoData/QstTest_160_0109.dat", "NemoData/QstTest_160_0110.dat", "NemoData/QstTest_160_0111.dat", "NemoData/QstTest_160_0112.dat", "NemoData/QstTest_160_0113.dat", "NemoData/QstTest_160_0114.dat", "NemoData/QstTest_160_0115.dat", "NemoData/QstTest_160_0116.dat", "NemoData/QstTest_160_0117.dat", "NemoData/QstTest_160_0118.dat", "NemoData/QstTest_160_0119.dat", "NemoData/QstTest_160_0120.dat", "NemoData/QstTest_160_0121.dat", "NemoData/QstTest_160_0122.dat", "NemoData/QstTest_160_0123.dat", "NemoData/QstTest_160_0124.dat", "NemoData/QstTest_160_0125.dat", "NemoData/QstTest_160_0126.dat", "NemoData/QstTest_160_0127.dat", "NemoData/QstTest_160_0128.dat", "NemoData/QstTest_160_0129.dat", "NemoData/QstTest_160_0130.dat", "NemoData/QstTest_160_0131.dat", "NemoData/QstTest_160_0132.dat", "NemoData/QstTest_160_0133.dat", "NemoData/QstTest_160_0134.dat", "NemoData/QstTest_160_0135.dat", "NemoData/QstTest_160_0136.dat", "NemoData/QstTest_160_0137.dat", "NemoData/QstTest_160_0138.dat", "NemoData/QstTest_160_0139.dat", "NemoData/QstTest_160_0140.dat", "NemoData/QstTest_160_0141.dat", "NemoData/QstTest_160_0142.dat", "NemoData/QstTest_160_0143.dat", "NemoData/QstTest_160_0144.dat", "NemoData/QstTest_160_0145.dat", "NemoData/QstTest_160_0146.dat", "NemoData/QstTest_160_0147.dat", "NemoData/QstTest_160_0148.dat", "NemoData/QstTest_160_0149.dat", "NemoData/QstTest_160_0150.dat", "NemoData/QstTest_160_0151.dat", "NemoData/QstTest_160_0152.dat", "NemoData/QstTest_160_0153.dat", "NemoData/QstTest_160_0154.dat", "NemoData/QstTest_160_0155.dat", "NemoData/QstTest_160_0156.dat", "NemoData/QstTest_160_0157.dat", "NemoData/QstTest_160_0158.dat", "NemoData/QstTest_160_0159.dat", "NemoData/QstTest_160_0160.dat", "NemoData/QstTest_160_0161.dat", "NemoData/QstTest_160_0162.dat", "NemoData/QstTest_160_0163.dat", "NemoData/QstTest_160_0164.dat", "NemoData/QstTest_160_0165.dat", "NemoData/QstTest_160_0166.dat", "NemoData/QstTest_160_0167.dat", "NemoData/QstTest_160_0168.dat", "NemoData/QstTest_160_0169.dat", "NemoData/QstTest_160_0170.dat", "NemoData/QstTest_160_0171.dat", "NemoData/QstTest_160_0172.dat", "NemoData/QstTest_160_0173.dat", "NemoData/QstTest_160_0174.dat", "NemoData/QstTest_160_0175.dat", "NemoData/QstTest_160_0176.dat", "NemoData/QstTest_160_0177.dat", "NemoData/QstTest_160_0178.dat", "NemoData/QstTest_160_0179.dat", "NemoData/QstTest_160_0180.dat", "NemoData/QstTest_160_0181.dat", "NemoData/QstTest_160_0182.dat", "NemoData/QstTest_160_0183.dat", "NemoData/QstTest_160_0184.dat", "NemoData/QstTest_160_0185.dat", "NemoData/QstTest_160_0186.dat", "NemoData/QstTest_160_0187.dat", "NemoData/QstTest_160_0188.dat", "NemoData/QstTest_160_0189.dat", "NemoData/QstTest_160_0190.dat", "NemoData/QstTest_160_0191.dat", "NemoData/QstTest_160_0192.dat", "NemoData/QstTest_160_0193.dat", "NemoData/QstTest_160_0194.dat", "NemoData/QstTest_160_0195.dat", "NemoData/QstTest_160_0196.dat", "NemoData/QstTest_160_0197.dat", "NemoData/QstTest_160_0198.dat", "NemoData/QstTest_160_0199.dat", "NemoData/QstTest_160_0200.dat", "NemoData/QstTest_160_0201.dat", "NemoData/QstTest_160_0202.dat", "NemoData/QstTest_160_0203.dat", "NemoData/QstTest_160_0204.dat", "NemoData/QstTest_160_0205.dat", "NemoData/QstTest_160_0206.dat", "NemoData/QstTest_160_0207.dat", "NemoData/QstTest_160_0208.dat", "NemoData/QstTest_160_0209.dat", "NemoData/QstTest_160_0210.dat", "NemoData/QstTest_160_0211.dat", "NemoData/QstTest_160_0212.dat", "NemoData/QstTest_160_0213.dat", "NemoData/QstTest_160_0214.dat", "NemoData/QstTest_160_0215.dat", "NemoData/QstTest_160_0216.dat", "NemoData/QstTest_160_0217.dat", "NemoData/QstTest_160_0218.dat", "NemoData/QstTest_160_0219.dat", "NemoData/QstTest_160_0220.dat", "NemoData/QstTest_160_0221.dat", "NemoData/QstTest_160_0222.dat", "NemoData/QstTest_160_0223.dat", "NemoData/QstTest_160_0224.dat", "NemoData/QstTest_160_0225.dat", "NemoData/QstTest_160_0226.dat", "NemoData/QstTest_160_0227.dat", "NemoData/QstTest_160_0228.dat", "NemoData/QstTest_160_0229.dat", "NemoData/QstTest_160_0230.dat", "NemoData/QstTest_160_0231.dat", "NemoData/QstTest_160_0232.dat", "NemoData/QstTest_160_0233.dat", "NemoData/QstTest_160_0234.dat", "NemoData/QstTest_160_0235.dat", "NemoData/QstTest_160_0236.dat", "NemoData/QstTest_160_0237.dat", "NemoData/QstTest_160_0238.dat", "NemoData/QstTest_160_0239.dat", "NemoData/QstTest_160_0240.dat", "NemoData/QstTest_160_0241.dat", "NemoData/QstTest_160_0242.dat", "NemoData/QstTest_160_0243.dat", "NemoData/QstTest_160_0244.dat", "NemoData/QstTest_160_0245.dat", "NemoData/QstTest_160_0246.dat", "NemoData/QstTest_160_0247.dat", "NemoData/QstTest_160_0248.dat", "NemoData/QstTest_160_0249.dat", "NemoData/QstTest_160_0250.dat", "NemoData/QstTest_160_0251.dat", "NemoData/QstTest_160_0252.dat", "NemoData/QstTest_160_0253.dat", "NemoData/QstTest_160_0254.dat", "NemoData/QstTest_160_0255.dat", "NemoData/QstTest_160_0256.dat", "NemoData/QstTest_160_0257.dat", "NemoData/QstTest_160_0258.dat", "NemoData/QstTest_160_0259.dat", "NemoData/QstTest_160_0260.dat", "NemoData/QstTest_160_0261.dat", "NemoData/QstTest_160_0262.dat", "NemoData/QstTest_160_0263.dat", "NemoData/QstTest_160_0264.dat", "NemoData/QstTest_160_0265.dat", "NemoData/QstTest_160_0266.dat", "NemoData/QstTest_160_0267.dat", "NemoData/QstTest_160_0268.dat", "NemoData/QstTest_160_0269.dat", "NemoData/QstTest_160_0270.dat", "NemoData/QstTest_160_0271.dat", "NemoData/QstTest_160_0272.dat", "NemoData/QstTest_160_0273.dat", "NemoData/QstTest_160_0274.dat", "NemoData/QstTest_160_0275.dat", "NemoData/QstTest_160_0276.dat", "NemoData/QstTest_160_0277.dat", "NemoData/QstTest_160_0278.dat", "NemoData/QstTest_160_0279.dat", "NemoData/QstTest_160_0280.dat", "NemoData/QstTest_160_0281.dat", "NemoData/QstTest_160_0282.dat", "NemoData/QstTest_160_0283.dat", "NemoData/QstTest_160_0284.dat", "NemoData/QstTest_160_0285.dat", "NemoData/QstTest_160_0286.dat", "NemoData/QstTest_160_0287.dat", "NemoData/QstTest_160_0288.dat", "NemoData/QstTest_160_0289.dat", "NemoData/QstTest_160_0290.dat", "NemoData/QstTest_160_0291.dat", "NemoData/QstTest_160_0292.dat", "NemoData/QstTest_160_0293.dat", "NemoData/QstTest_160_0294.dat", "NemoData/QstTest_160_0295.dat", "NemoData/QstTest_160_0296.dat", "NemoData/QstTest_160_0297.dat", "NemoData/QstTest_160_0298.dat", "NemoData/QstTest_160_0299.dat", "NemoData/QstTest_160_0300.dat", "NemoData/QstTest_160_0301.dat", "NemoData/QstTest_160_0302.dat", "NemoData/QstTest_160_0303.dat", "NemoData/QstTest_160_0304.dat", "NemoData/QstTest_160_0305.dat", "NemoData/QstTest_160_0306.dat", "NemoData/QstTest_160_0307.dat", "NemoData/QstTest_160_0308.dat", "NemoData/QstTest_160_0309.dat", "NemoData/QstTest_160_0310.dat", "NemoData/QstTest_160_0311.dat", "NemoData/QstTest_160_0312.dat", "NemoData/QstTest_160_0313.dat", "NemoData/QstTest_160_0314.dat", "NemoData/QstTest_160_0315.dat", "NemoData/QstTest_160_0316.dat", "NemoData/QstTest_160_0317.dat", "NemoData/QstTest_160_0318.dat", "NemoData/QstTest_160_0319.dat", "NemoData/QstTest_160_0320.dat", "NemoData/QstTest_160_0321.dat", "NemoData/QstTest_160_0322.dat", "NemoData/QstTest_160_0323.dat", "NemoData/QstTest_160_0324.dat", "NemoData/QstTest_160_0325.dat", "NemoData/QstTest_160_0326.dat", "NemoData/QstTest_160_0327.dat", "NemoData/QstTest_160_0328.dat", "NemoData/QstTest_160_0329.dat", "NemoData/QstTest_160_0330.dat", "NemoData/QstTest_160_0331.dat", "NemoData/QstTest_160_0332.dat", "NemoData/QstTest_160_0333.dat", "NemoData/QstTest_160_0334.dat", "NemoData/QstTest_160_0335.dat", "NemoData/QstTest_160_0336.dat", "NemoData/QstTest_160_0337.dat", "NemoData/QstTest_160_0338.dat", "NemoData/QstTest_160_0339.dat", "NemoData/QstTest_160_0340.dat", "NemoData/QstTest_160_0341.dat", "NemoData/QstTest_160_0342.dat", "NemoData/QstTest_160_0343.dat", "NemoData/QstTest_160_0344.dat", "NemoData/QstTest_160_0345.dat", "NemoData/QstTest_160_0346.dat", "NemoData/QstTest_160_0347.dat", "NemoData/QstTest_160_0348.dat", "NemoData/QstTest_160_0349.dat", "NemoData/QstTest_160_0350.dat", "NemoData/QstTest_160_0351.dat", "NemoData/QstTest_160_0352.dat", "NemoData/QstTest_160_0353.dat", "NemoData/QstTest_160_0354.dat", "NemoData/QstTest_160_0355.dat", "NemoData/QstTest_160_0356.dat", "NemoData/QstTest_160_0357.dat", "NemoData/QstTest_160_0358.dat", "NemoData/QstTest_160_0359.dat", "NemoData/QstTest_160_0360.dat", "NemoData/QstTest_160_0361.dat", "NemoData/QstTest_160_0362.dat", "NemoData/QstTest_160_0363.dat", "NemoData/QstTest_160_0364.dat", "NemoData/QstTest_160_0365.dat", "NemoData/QstTest_160_0366.dat", "NemoData/QstTest_160_0367.dat", "NemoData/QstTest_160_0368.dat", "NemoData/QstTest_160_0369.dat", "NemoData/QstTest_160_0370.dat", "NemoData/QstTest_160_0371.dat", "NemoData/QstTest_160_0372.dat", "NemoData/QstTest_160_0373.dat", "NemoData/QstTest_160_0374.dat", "NemoData/QstTest_160_0375.dat", "NemoData/QstTest_160_0376.dat", "NemoData/QstTest_160_0377.dat", "NemoData/QstTest_160_0378.dat", "NemoData/QstTest_160_0379.dat", "NemoData/QstTest_160_0380.dat", "NemoData/QstTest_160_0381.dat", "NemoData/QstTest_160_0382.dat", "NemoData/QstTest_160_0383.dat", "NemoData/QstTest_160_0384.dat", "NemoData/QstTest_160_0385.dat", "NemoData/QstTest_160_0386.dat", "NemoData/QstTest_160_0387.dat", "NemoData/QstTest_160_0388.dat", "NemoData/QstTest_160_0389.dat", "NemoData/QstTest_160_0390.dat", "NemoData/QstTest_160_0391.dat", "NemoData/QstTest_160_0392.dat", "NemoData/QstTest_160_0393.dat", "NemoData/QstTest_160_0394.dat", "NemoData/QstTest_160_0395.dat", "NemoData/QstTest_160_0396.dat", "NemoData/QstTest_160_0397.dat", "NemoData/QstTest_160_0398.dat", "NemoData/QstTest_160_0399.dat", "NemoData/QstTest_160_0400.dat", "NemoData/QstTest_160_0401.dat", "NemoData/QstTest_160_0402.dat", "NemoData/QstTest_160_0403.dat", "NemoData/QstTest_160_0404.dat", "NemoData/QstTest_160_0405.dat", "NemoData/QstTest_160_0406.dat", "NemoData/QstTest_160_0407.dat", "NemoData/QstTest_160_0408.dat", "NemoData/QstTest_160_0409.dat", "NemoData/QstTest_160_0410.dat", "NemoData/QstTest_160_0411.dat", "NemoData/QstTest_160_0412.dat", "NemoData/QstTest_160_0413.dat", "NemoData/QstTest_160_0414.dat", "NemoData/QstTest_160_0415.dat", "NemoData/QstTest_160_0416.dat", "NemoData/QstTest_160_0417.dat", "NemoData/QstTest_160_0418.dat", "NemoData/QstTest_160_0419.dat", "NemoData/QstTest_160_0420.dat", "NemoData/QstTest_160_0421.dat", "NemoData/QstTest_160_0422.dat", "NemoData/QstTest_160_0423.dat", "NemoData/QstTest_160_0424.dat", "NemoData/QstTest_160_0425.dat", "NemoData/QstTest_160_0426.dat", "NemoData/QstTest_160_0427.dat", "NemoData/QstTest_160_0428.dat", "NemoData/QstTest_160_0429.dat", "NemoData/QstTest_160_0430.dat", "NemoData/QstTest_160_0431.dat", "NemoData/QstTest_160_0432.dat", "NemoData/QstTest_160_0433.dat", "NemoData/QstTest_160_0434.dat", "NemoData/QstTest_160_0435.dat", "NemoData/QstTest_160_0436.dat", "NemoData/QstTest_160_0437.dat", "NemoData/QstTest_160_0438.dat", "NemoData/QstTest_160_0439.dat", "NemoData/QstTest_160_0440.dat", "NemoData/QstTest_160_0441.dat", "NemoData/QstTest_160_0442.dat", "NemoData/QstTest_160_0443.dat", "NemoData/QstTest_160_0444.dat", "NemoData/QstTest_160_0445.dat", "NemoData/QstTest_160_0446.dat", "NemoData/QstTest_160_0447.dat", "NemoData/QstTest_160_0448.dat", "NemoData/QstTest_160_0449.dat", "NemoData/QstTest_160_0450.dat", "NemoData/QstTest_160_0451.dat", "NemoData/QstTest_160_0452.dat", "NemoData/QstTest_160_0453.dat", "NemoData/QstTest_160_0454.dat", "NemoData/QstTest_160_0455.dat", "NemoData/QstTest_160_0456.dat", "NemoData/QstTest_160_0457.dat", "NemoData/QstTest_160_0458.dat", "NemoData/QstTest_160_0459.dat", "NemoData/QstTest_160_0460.dat", "NemoData/QstTest_160_0461.dat", "NemoData/QstTest_160_0462.dat", "NemoData/QstTest_160_0463.dat", "NemoData/QstTest_160_0464.dat", "NemoData/QstTest_160_0465.dat", "NemoData/QstTest_160_0466.dat", "NemoData/QstTest_160_0467.dat", "NemoData/QstTest_160_0468.dat", "NemoData/QstTest_160_0469.dat", "NemoData/QstTest_160_0470.dat", "NemoData/QstTest_160_0471.dat", "NemoData/QstTest_160_0472.dat", "NemoData/QstTest_160_0473.dat", "NemoData/QstTest_160_0474.dat", "NemoData/QstTest_160_0475.dat", "NemoData/QstTest_160_0476.dat", "NemoData/QstTest_160_0477.dat", "NemoData/QstTest_160_0478.dat", "NemoData/QstTest_160_0479.dat", "NemoData/QstTest_160_0480.dat", "NemoData/QstTest_160_0481.dat", "NemoData/QstTest_160_0482.dat", "NemoData/QstTest_160_0483.dat", "NemoData/QstTest_160_0484.dat", "NemoData/QstTest_160_0485.dat", "NemoData/QstTest_160_0486.dat", "NemoData/QstTest_160_0487.dat", "NemoData/QstTest_160_0488.dat", "NemoData/QstTest_160_0489.dat", "NemoData/QstTest_160_0490.dat", "NemoData/QstTest_160_0491.dat", "NemoData/QstTest_160_0492.dat", "NemoData/QstTest_160_0493.dat", "NemoData/QstTest_160_0494.dat", "NemoData/QstTest_160_0495.dat", "NemoData/QstTest_160_0496.dat", "NemoData/QstTest_160_0497.dat", "NemoData/QstTest_160_0498.dat", "NemoData/QstTest_160_0499.dat", "NemoData/QstTest_160_0500.dat", "NemoData/QstTest_160_0501.dat", "NemoData/QstTest_160_0502.dat", "NemoData/QstTest_160_0503.dat", "NemoData/QstTest_160_0504.dat", "NemoData/QstTest_160_0505.dat", "NemoData/QstTest_160_0506.dat", "NemoData/QstTest_160_0507.dat", "NemoData/QstTest_160_0508.dat", "NemoData/QstTest_160_0509.dat", "NemoData/QstTest_160_0510.dat", "NemoData/QstTest_160_0511.dat", "NemoData/QstTest_160_0512.dat", "NemoData/QstTest_160_0513.dat", "NemoData/QstTest_160_0514.dat", "NemoData/QstTest_160_0515.dat", "NemoData/QstTest_160_0516.dat", "NemoData/QstTest_160_0517.dat", "NemoData/QstTest_160_0518.dat", "NemoData/QstTest_160_0519.dat", "NemoData/QstTest_160_0520.dat", "NemoData/QstTest_160_0521.dat", "NemoData/QstTest_160_0522.dat", "NemoData/QstTest_160_0523.dat", "NemoData/QstTest_160_0524.dat", "NemoData/QstTest_160_0525.dat", "NemoData/QstTest_160_0526.dat", "NemoData/QstTest_160_0527.dat", "NemoData/QstTest_160_0528.dat", "NemoData/QstTest_160_0529.dat", "NemoData/QstTest_160_0530.dat", "NemoData/QstTest_160_0531.dat", "NemoData/QstTest_160_0532.dat", "NemoData/QstTest_160_0533.dat", "NemoData/QstTest_160_0534.dat", "NemoData/QstTest_160_0535.dat", "NemoData/QstTest_160_0536.dat", "NemoData/QstTest_160_0537.dat", "NemoData/QstTest_160_0538.dat", "NemoData/QstTest_160_0539.dat", "NemoData/QstTest_160_0540.dat", "NemoData/QstTest_160_0541.dat", "NemoData/QstTest_160_0542.dat", "NemoData/QstTest_160_0543.dat", "NemoData/QstTest_160_0544.dat", "NemoData/QstTest_160_0545.dat", "NemoData/QstTest_160_0546.dat", "NemoData/QstTest_160_0547.dat", "NemoData/QstTest_160_0548.dat", "NemoData/QstTest_160_0549.dat", "NemoData/QstTest_160_0550.dat", "NemoData/QstTest_160_0551.dat", "NemoData/QstTest_160_0552.dat", "NemoData/QstTest_160_0553.dat", "NemoData/QstTest_160_0554.dat", "NemoData/QstTest_160_0555.dat", "NemoData/QstTest_160_0556.dat", "NemoData/QstTest_160_0557.dat", "NemoData/QstTest_160_0558.dat", "NemoData/QstTest_160_0559.dat", "NemoData/QstTest_160_0560.dat", "NemoData/QstTest_160_0561.dat", "NemoData/QstTest_160_0562.dat", "NemoData/QstTest_160_0563.dat", "NemoData/QstTest_160_0564.dat", "NemoData/QstTest_160_0565.dat", "NemoData/QstTest_160_0566.dat", "NemoData/QstTest_160_0567.dat", "NemoData/QstTest_160_0568.dat", "NemoData/QstTest_160_0569.dat", "NemoData/QstTest_160_0570.dat", "NemoData/QstTest_160_0571.dat", "NemoData/QstTest_160_0572.dat", "NemoData/QstTest_160_0573.dat", "NemoData/QstTest_160_0574.dat", "NemoData/QstTest_160_0575.dat", "NemoData/QstTest_160_0576.dat", "NemoData/QstTest_160_0577.dat", "NemoData/QstTest_160_0578.dat", "NemoData/QstTest_160_0579.dat", "NemoData/QstTest_160_0580.dat", "NemoData/QstTest_160_0581.dat", "NemoData/QstTest_160_0582.dat", "NemoData/QstTest_160_0583.dat", "NemoData/QstTest_160_0584.dat", "NemoData/QstTest_160_0585.dat", "NemoData/QstTest_160_0586.dat", "NemoData/QstTest_160_0587.dat", "NemoData/QstTest_160_0588.dat", "NemoData/QstTest_160_0589.dat", "NemoData/QstTest_160_0590.dat", "NemoData/QstTest_160_0591.dat", "NemoData/QstTest_160_0592.dat", "NemoData/QstTest_160_0593.dat", "NemoData/QstTest_160_0594.dat", "NemoData/QstTest_160_0595.dat", "NemoData/QstTest_160_0596.dat", "NemoData/QstTest_160_0597.dat", "NemoData/QstTest_160_0598.dat", "NemoData/QstTest_160_0599.dat", "NemoData/QstTest_160_0600.dat", "NemoData/QstTest_160_0601.dat", "NemoData/QstTest_160_0602.dat", "NemoData/QstTest_160_0603.dat", "NemoData/QstTest_160_0604.dat", "NemoData/QstTest_160_0605.dat", "NemoData/QstTest_160_0606.dat", "NemoData/QstTest_160_0607.dat", "NemoData/QstTest_160_0608.dat", "NemoData/QstTest_160_0609.dat", "NemoData/QstTest_160_0610.dat", "NemoData/QstTest_160_0611.dat", "NemoData/QstTest_160_0612.dat", "NemoData/QstTest_160_0613.dat", "NemoData/QstTest_160_0614.dat", "NemoData/QstTest_160_0615.dat", "NemoData/QstTest_160_0616.dat", "NemoData/QstTest_160_0617.dat", "NemoData/QstTest_160_0618.dat", "NemoData/QstTest_160_0619.dat", "NemoData/QstTest_160_0620.dat", "NemoData/QstTest_160_0621.dat", "NemoData/QstTest_160_0622.dat", "NemoData/QstTest_160_0623.dat", "NemoData/QstTest_160_0624.dat", "NemoData/QstTest_160_0625.dat", "NemoData/QstTest_160_0626.dat", "NemoData/QstTest_160_0627.dat", "NemoData/QstTest_160_0628.dat", "NemoData/QstTest_160_0629.dat", "NemoData/QstTest_160_0630.dat", "NemoData/QstTest_160_0631.dat", "NemoData/QstTest_160_0632.dat", "NemoData/QstTest_160_0633.dat", "NemoData/QstTest_160_0634.dat", "NemoData/QstTest_160_0635.dat", "NemoData/QstTest_160_0636.dat", "NemoData/QstTest_160_0637.dat", "NemoData/QstTest_160_0638.dat", "NemoData/QstTest_160_0639.dat", "NemoData/QstTest_160_0640.dat", "NemoData/QstTest_160_0641.dat", "NemoData/QstTest_160_0642.dat", "NemoData/QstTest_160_0643.dat", "NemoData/QstTest_160_0644.dat", "NemoData/QstTest_160_0645.dat", "NemoData/QstTest_160_0646.dat", "NemoData/QstTest_160_0647.dat", "NemoData/QstTest_160_0648.dat", "NemoData/QstTest_160_0649.dat", "NemoData/QstTest_160_0650.dat", "NemoData/QstTest_160_0651.dat", "NemoData/QstTest_160_0652.dat", "NemoData/QstTest_160_0653.dat", "NemoData/QstTest_160_0654.dat", "NemoData/QstTest_160_0655.dat", "NemoData/QstTest_160_0656.dat", "NemoData/QstTest_160_0657.dat", "NemoData/QstTest_160_0658.dat", "NemoData/QstTest_160_0659.dat", "NemoData/QstTest_160_0660.dat", "NemoData/QstTest_160_0661.dat", "NemoData/QstTest_160_0662.dat", "NemoData/QstTest_160_0663.dat", "NemoData/QstTest_160_0664.dat", "NemoData/QstTest_160_0665.dat", "NemoData/QstTest_160_0666.dat", "NemoData/QstTest_160_0667.dat", "NemoData/QstTest_160_0668.dat", "NemoData/QstTest_160_0669.dat", "NemoData/QstTest_160_0670.dat", "NemoData/QstTest_160_0671.dat", "NemoData/QstTest_160_0672.dat", "NemoData/QstTest_160_0673.dat", "NemoData/QstTest_160_0674.dat", "NemoData/QstTest_160_0675.dat", "NemoData/QstTest_160_0676.dat", "NemoData/QstTest_160_0677.dat", "NemoData/QstTest_160_0678.dat", "NemoData/QstTest_160_0679.dat", "NemoData/QstTest_160_0680.dat", "NemoData/QstTest_160_0681.dat", "NemoData/QstTest_160_0682.dat", "NemoData/QstTest_160_0683.dat", "NemoData/QstTest_160_0684.dat", "NemoData/QstTest_160_0685.dat", "NemoData/QstTest_160_0686.dat", "NemoData/QstTest_160_0687.dat", "NemoData/QstTest_160_0688.dat", "NemoData/QstTest_160_0689.dat", "NemoData/QstTest_160_0690.dat", "NemoData/QstTest_160_0691.dat", "NemoData/QstTest_160_0692.dat", "NemoData/QstTest_160_0693.dat", "NemoData/QstTest_160_0694.dat", "NemoData/QstTest_160_0695.dat", "NemoData/QstTest_160_0696.dat", "NemoData/QstTest_160_0697.dat", "NemoData/QstTest_160_0698.dat", "NemoData/QstTest_160_0699.dat", "NemoData/QstTest_160_0700.dat", "NemoData/QstTest_160_0701.dat", "NemoData/QstTest_160_0702.dat", "NemoData/QstTest_160_0703.dat", "NemoData/QstTest_160_0704.dat", "NemoData/QstTest_160_0705.dat", "NemoData/QstTest_160_0706.dat", "NemoData/QstTest_160_0707.dat", "NemoData/QstTest_160_0708.dat", "NemoData/QstTest_160_0709.dat", "NemoData/QstTest_160_0710.dat", "NemoData/QstTest_160_0711.dat", "NemoData/QstTest_160_0712.dat", "NemoData/QstTest_160_0713.dat", "NemoData/QstTest_160_0714.dat", "NemoData/QstTest_160_0715.dat", "NemoData/QstTest_160_0716.dat", "NemoData/QstTest_160_0717.dat", "NemoData/QstTest_160_0718.dat", "NemoData/QstTest_160_0719.dat", "NemoData/QstTest_160_0720.dat", "NemoData/QstTest_160_0721.dat", "NemoData/QstTest_160_0722.dat", "NemoData/QstTest_160_0723.dat", "NemoData/QstTest_160_0724.dat", "NemoData/QstTest_160_0725.dat", "NemoData/QstTest_160_0726.dat", "NemoData/QstTest_160_0727.dat", "NemoData/QstTest_160_0728.dat", "NemoData/QstTest_160_0729.dat", "NemoData/QstTest_160_0730.dat", "NemoData/QstTest_160_0731.dat", "NemoData/QstTest_160_0732.dat", "NemoData/QstTest_160_0733.dat", "NemoData/QstTest_160_0734.dat", "NemoData/QstTest_160_0735.dat", "NemoData/QstTest_160_0736.dat", "NemoData/QstTest_160_0737.dat", "NemoData/QstTest_160_0738.dat", "NemoData/QstTest_160_0739.dat", "NemoData/QstTest_160_0740.dat", "NemoData/QstTest_160_0741.dat", "NemoData/QstTest_160_0742.dat", "NemoData/QstTest_160_0743.dat", "NemoData/QstTest_160_0744.dat", "NemoData/QstTest_160_0745.dat", "NemoData/QstTest_160_0746.dat", "NemoData/QstTest_160_0747.dat", "NemoData/QstTest_160_0748.dat", "NemoData/QstTest_160_0749.dat", "NemoData/QstTest_160_0750.dat", "NemoData/QstTest_160_0751.dat", "NemoData/QstTest_160_0752.dat", "NemoData/QstTest_160_0753.dat", "NemoData/QstTest_160_0754.dat", "NemoData/QstTest_160_0755.dat", "NemoData/QstTest_160_0756.dat", "NemoData/QstTest_160_0757.dat", "NemoData/QstTest_160_0758.dat", "NemoData/QstTest_160_0759.dat", "NemoData/QstTest_160_0760.dat", "NemoData/QstTest_160_0761.dat", "NemoData/QstTest_160_0762.dat", "NemoData/QstTest_160_0763.dat", "NemoData/QstTest_160_0764.dat", "NemoData/QstTest_160_0765.dat", "NemoData/QstTest_160_0766.dat", "NemoData/QstTest_160_0767.dat", "NemoData/QstTest_160_0768.dat", "NemoData/QstTest_160_0769.dat", "NemoData/QstTest_160_0770.dat", "NemoData/QstTest_160_0771.dat", "NemoData/QstTest_160_0772.dat", "NemoData/QstTest_160_0773.dat", "NemoData/QstTest_160_0774.dat", "NemoData/QstTest_160_0775.dat", "NemoData/QstTest_160_0776.dat", "NemoData/QstTest_160_0777.dat", "NemoData/QstTest_160_0778.dat", "NemoData/QstTest_160_0779.dat", "NemoData/QstTest_160_0780.dat", "NemoData/QstTest_160_0781.dat", "NemoData/QstTest_160_0782.dat", "NemoData/QstTest_160_0783.dat", "NemoData/QstTest_160_0784.dat", "NemoData/QstTest_160_0785.dat", "NemoData/QstTest_160_0786.dat", "NemoData/QstTest_160_0787.dat", "NemoData/QstTest_160_0788.dat", "NemoData/QstTest_160_0789.dat", "NemoData/QstTest_160_0790.dat", "NemoData/QstTest_160_0791.dat", "NemoData/QstTest_160_0792.dat", "NemoData/QstTest_160_0793.dat", "NemoData/QstTest_160_0794.dat", "NemoData/QstTest_160_0795.dat", "NemoData/QstTest_160_0796.dat", "NemoData/QstTest_160_0797.dat", "NemoData/QstTest_160_0798.dat", "NemoData/QstTest_160_0799.dat", "NemoData/QstTest_160_0800.dat", "NemoData/QstTest_160_0801.dat", "NemoData/QstTest_160_0802.dat", "NemoData/QstTest_160_0803.dat", "NemoData/QstTest_160_0804.dat", "NemoData/QstTest_160_0805.dat", "NemoData/QstTest_160_0806.dat", "NemoData/QstTest_160_0807.dat", "NemoData/QstTest_160_0808.dat", "NemoData/QstTest_160_0809.dat", "NemoData/QstTest_160_0810.dat", "NemoData/QstTest_160_0811.dat", "NemoData/QstTest_160_0812.dat", "NemoData/QstTest_160_0813.dat", "NemoData/QstTest_160_0814.dat", "NemoData/QstTest_160_0815.dat", "NemoData/QstTest_160_0816.dat", "NemoData/QstTest_160_0817.dat", "NemoData/QstTest_160_0818.dat", "NemoData/QstTest_160_0819.dat", "NemoData/QstTest_160_0820.dat", "NemoData/QstTest_160_0821.dat", "NemoData/QstTest_160_0822.dat", "NemoData/QstTest_160_0823.dat", "NemoData/QstTest_160_0824.dat", "NemoData/QstTest_160_0825.dat", "NemoData/QstTest_160_0826.dat", "NemoData/QstTest_160_0827.dat", "NemoData/QstTest_160_0828.dat", "NemoData/QstTest_160_0829.dat", "NemoData/QstTest_160_0830.dat", "NemoData/QstTest_160_0831.dat", "NemoData/QstTest_160_0832.dat", "NemoData/QstTest_160_0833.dat", "NemoData/QstTest_160_0834.dat", "NemoData/QstTest_160_0835.dat", "NemoData/QstTest_160_0836.dat", "NemoData/QstTest_160_0837.dat", "NemoData/QstTest_160_0838.dat", "NemoData/QstTest_160_0839.dat", "NemoData/QstTest_160_0840.dat", "NemoData/QstTest_160_0841.dat", "NemoData/QstTest_160_0842.dat", "NemoData/QstTest_160_0843.dat", "NemoData/QstTest_160_0844.dat", "NemoData/QstTest_160_0845.dat", "NemoData/QstTest_160_0846.dat", "NemoData/QstTest_160_0847.dat", "NemoData/QstTest_160_0848.dat", "NemoData/QstTest_160_0849.dat", "NemoData/QstTest_160_0850.dat", "NemoData/QstTest_160_0851.dat", "NemoData/QstTest_160_0852.dat", "NemoData/QstTest_160_0853.dat", "NemoData/QstTest_160_0854.dat", "NemoData/QstTest_160_0855.dat", "NemoData/QstTest_160_0856.dat", "NemoData/QstTest_160_0857.dat", "NemoData/QstTest_160_0858.dat", "NemoData/QstTest_160_0859.dat", "NemoData/QstTest_160_0860.dat", "NemoData/QstTest_160_0861.dat", "NemoData/QstTest_160_0862.dat", "NemoData/QstTest_160_0863.dat", "NemoData/QstTest_160_0864.dat", "NemoData/QstTest_160_0865.dat", "NemoData/QstTest_160_0866.dat", "NemoData/QstTest_160_0867.dat", "NemoData/QstTest_160_0868.dat", "NemoData/QstTest_160_0869.dat", "NemoData/QstTest_160_0870.dat", "NemoData/QstTest_160_0871.dat", "NemoData/QstTest_160_0872.dat", "NemoData/QstTest_160_0873.dat", "NemoData/QstTest_160_0874.dat", "NemoData/QstTest_160_0875.dat", "NemoData/QstTest_160_0876.dat", "NemoData/QstTest_160_0877.dat", "NemoData/QstTest_160_0878.dat", "NemoData/QstTest_160_0879.dat", "NemoData/QstTest_160_0880.dat", "NemoData/QstTest_160_0881.dat", "NemoData/QstTest_160_0882.dat", "NemoData/QstTest_160_0883.dat", "NemoData/QstTest_160_0884.dat", "NemoData/QstTest_160_0885.dat", "NemoData/QstTest_160_0886.dat", "NemoData/QstTest_160_0887.dat", "NemoData/QstTest_160_0888.dat", "NemoData/QstTest_160_0889.dat", "NemoData/QstTest_160_0890.dat", "NemoData/QstTest_160_0891.dat", "NemoData/QstTest_160_0892.dat", "NemoData/QstTest_160_0893.dat", "NemoData/QstTest_160_0894.dat", "NemoData/QstTest_160_0895.dat", "NemoData/QstTest_160_0896.dat", "NemoData/QstTest_160_0897.dat", "NemoData/QstTest_160_0898.dat", "NemoData/QstTest_160_0899.dat", "NemoData/QstTest_160_0900.dat", "NemoData/QstTest_160_0901.dat", "NemoData/QstTest_160_0902.dat", "NemoData/QstTest_160_0903.dat", "NemoData/QstTest_160_0904.dat", "NemoData/QstTest_160_0905.dat", "NemoData/QstTest_160_0906.dat", "NemoData/QstTest_160_0907.dat", "NemoData/QstTest_160_0908.dat", "NemoData/QstTest_160_0909.dat", "NemoData/QstTest_160_0910.dat", "NemoData/QstTest_160_0911.dat", "NemoData/QstTest_160_0912.dat", "NemoData/QstTest_160_0913.dat", "NemoData/QstTest_160_0914.dat", "NemoData/QstTest_160_0915.dat", "NemoData/QstTest_160_0916.dat", "NemoData/QstTest_160_0917.dat", "NemoData/QstTest_160_0918.dat", "NemoData/QstTest_160_0919.dat", "NemoData/QstTest_160_0920.dat", "NemoData/QstTest_160_0921.dat", "NemoData/QstTest_160_0922.dat", "NemoData/QstTest_160_0923.dat", "NemoData/QstTest_160_0924.dat", "NemoData/QstTest_160_0925.dat", "NemoData/QstTest_160_0926.dat", "NemoData/QstTest_160_0927.dat", "NemoData/QstTest_160_0928.dat", "NemoData/QstTest_160_0929.dat", "NemoData/QstTest_160_0930.dat", "NemoData/QstTest_160_0931.dat", "NemoData/QstTest_160_0932.dat", "NemoData/QstTest_160_0933.dat", "NemoData/QstTest_160_0934.dat", "NemoData/QstTest_160_0935.dat", "NemoData/QstTest_160_0936.dat", "NemoData/QstTest_160_0937.dat", "NemoData/QstTest_160_0938.dat", "NemoData/QstTest_160_0939.dat", "NemoData/QstTest_160_0940.dat", "NemoData/QstTest_160_0941.dat", "NemoData/QstTest_160_0942.dat", "NemoData/QstTest_160_0943.dat", "NemoData/QstTest_160_0944.dat", "NemoData/QstTest_160_0945.dat", "NemoData/QstTest_160_0946.dat", "NemoData/QstTest_160_0947.dat", "NemoData/QstTest_160_0948.dat", "NemoData/QstTest_160_0949.dat", "NemoData/QstTest_160_0950.dat", "NemoData/QstTest_160_0951.dat", "NemoData/QstTest_160_0952.dat", "NemoData/QstTest_160_0953.dat", "NemoData/QstTest_160_0954.dat", "NemoData/QstTest_160_0955.dat", "NemoData/QstTest_160_0956.dat", "NemoData/QstTest_160_0957.dat", "NemoData/QstTest_160_0958.dat", "NemoData/QstTest_160_0959.dat", "NemoData/QstTest_160_0960.dat", "NemoData/QstTest_160_0961.dat", "NemoData/QstTest_160_0962.dat", "NemoData/QstTest_160_0963.dat", "NemoData/QstTest_160_0964.dat", "NemoData/QstTest_160_0965.dat", "NemoData/QstTest_160_0966.dat", "NemoData/QstTest_160_0967.dat", "NemoData/QstTest_160_0968.dat", "NemoData/QstTest_160_0969.dat", "NemoData/QstTest_160_0970.dat", "NemoData/QstTest_160_0971.dat", "NemoData/QstTest_160_0972.dat", "NemoData/QstTest_160_0973.dat", "NemoData/QstTest_160_0974.dat", "NemoData/QstTest_160_0975.dat", "NemoData/QstTest_160_0976.dat", "NemoData/QstTest_160_0977.dat", "NemoData/QstTest_160_0978.dat", "NemoData/QstTest_160_0979.dat", "NemoData/QstTest_160_0980.dat", "NemoData/QstTest_160_0981.dat", "NemoData/QstTest_160_0982.dat", "NemoData/QstTest_160_0983.dat", "NemoData/QstTest_160_0984.dat", "NemoData/QstTest_160_0985.dat", "NemoData/QstTest_160_0986.dat", "NemoData/QstTest_160_0987.dat", "NemoData/QstTest_160_0988.dat", "NemoData/QstTest_160_0989.dat", "NemoData/QstTest_160_0990.dat", "NemoData/QstTest_160_0991.dat", "NemoData/QstTest_160_0992.dat", "NemoData/QstTest_160_0993.dat", "NemoData/QstTest_160_0994.dat", "NemoData/QstTest_160_0995.dat", "NemoData/QstTest_160_0996.dat", "NemoData/QstTest_160_0997.dat", "NemoData/QstTest_160_0998.dat", "NemoData/QstTest_160_0999.dat", "NemoData/QstTest_160_1000.dat") # this will create a function to take the nemo data, sample it to calculate Fst, sample it to get individuals, perform breeding and make offspring meeting the specified breeding design # 15 POPS # 5 SIRES PER POP # 3 DAMS PER SIRE # 8 OFFSPRING PER DAM, CULLED TO 4 ON AVERAGE # 20 INDS SAMPLED FOR Fst CALCULATION nemo.qst <- function (dat, npops=15, ndams=15, nsires=5, inds.per.pop=200, num.to.sample=20) { x <- scan(dat, n = 4) #read first line of file, gives number of loci, alleles, etc #first line tells me: 15 patches, number of loci + 4, number of alleles, digits per genotype nloc <- x[2]-4 #get number of loci (-4 because nemo adds 4 extra rows where loci are) lnames <- scan(dat, what = character(), skip = 1, nlines = nloc) #locus names lnames <- c("Pop", lnames) #add first column heading name to be "pop" genos <- scan(dat, skip = nloc + 5)#, what = character()) #read genotype data #adding what=character reads data as characters instead of numbers and keeps the leading zeroes genos <- data.frame(matrix(genos, ncol = nloc + 5, byrow = TRUE)) #genotype data in matrix format now genos <- genos[,-((length(genos[1,])-3):length(genos[1,]))] #remove last 4 columns of nemo data names(genos) <- lnames #add column names geno.mat <- genos[,1] for(i in 2:251){ temp.mat <- matrix((as.numeric(unlist(strsplit(as.character(genos[,i]), split=0)))-1), nrow=3000, ncol=2, byrow=TRUE) geno.mat <- cbind(geno.mat, temp.mat) } geno.dat <- as.data.frame(geno.mat) ## THIS GIVES ME A MATRIX OF 501 COLUMNS, WITH FIRST COLUMN AS POP ID AND NEXT TWO COLUMNS EACH OF 2 ALLELES FOR THAT INDIVIDUALS GENOTYPE, ACCORDINGLY THROUGH 250 LOCI ## 3000 individuals # get Fst data, columns 2-202 # make it numeric # multiply the 2 alleles together to get the visible genotype (AFLPs are dominant) geno.mat <- matrix(NA, ncol=100, nrow=3000) allele.cols <- seq(2,200,by=2) jj <- 1 for(i in 2:101){ geno.mat[,jj] <- geno.dat[,i]*geno.dat[,i+1] jj <- jj + 1 } genotypes <- cbind(genos[,1], geno.mat) ### CALCULATE Q_hat VALUES (a la AFLP SURV) calc.q_hat <- function(x, N){ q_hat <- x^(1/2) * (1-( ((x*(1-x))/N) / (8*x^2) ))^-1 if(x==0) q_hat <- 0 return(q_hat) } ### CALCULATE Q_var VALUES (a la AFLP SURV) calc.varq <- function(x, N){ qvar <- (1-x)/(4*N) return(qvar) } ## SAMPLE 20 INDS TO GET FST samps.per.pop <- sample(1:200, size=20, replace=FALSE) inds.to.take <- c(samps.per.pop, samps.per.pop+200, samps.per.pop+400, samps.per.pop+600, samps.per.pop+800, samps.per.pop+1000, samps.per.pop+1200, samps.per.pop+1400, samps.per.pop+1600, samps.per.pop+1800, samps.per.pop+2000, samps.per.pop+2200, samps.per.pop+2400, samps.per.pop+2600, samps.per.pop+2800) genotypes <- genotypes[inds.to.take,] q_hat.matrix <- as.data.frame(matrix(NA, nrow=100, ncol=npops)) qvar.matrix <- as.data.frame(matrix(NA, nrow=100, ncol= npops)) N <- 20 # balanced design, sample size per pop is 200 for(i in 1:npops){ # for one pop go through all the loci temp.genos <- subset(genotypes, genotypes[,1]==i) temp.x_hats <- colSums(temp.genos[,2:101])/N temp.q_hats <- lapply(temp.x_hats, N, FUN=calc.q_hat) # these are the q_hats for one pop across all 100 loci temp.varq <- lapply(temp.x_hats, N, FUN=calc.varq) q_hat.matrix[,i] <- unlist(temp.q_hats) qvar.matrix[,i] <- unlist(temp.varq) } simulated.fst.dat <- cbind(q_hat.matrix, qvar.matrix) write.csv(simulated.fst.dat, file="FstData_SireUnbalancedTest.csv") # get Qst data, columns 102-251 # sum across all rows to get phenotype # subtract 1 to get 0's and 1's (AFLPs) pheno.mat.dam <- matrix(NA, ncol=300, nrow=3000) pheno.mat.sire <- matrix(NA, ncol=300, nrow=3000) i.list <- seq(202, 500, by=2) z <- 1 y <- 1 for(i in i.list){ pheno.mat.sire[,z] <- geno.dat[,i] # as.data.frame(matrix(as.numeric(geno.dat[,i]), ncol=2)-1)[,1] pheno.mat.sire[,(z+1)] <- geno.dat[,(i+1)] # as.data.frame(matrix(as.numeric(genos[,i]), ncol=2)-1)[,2] pheno.mat.dam[,y] <- geno.dat[,i] # (matrix(as.numeric(genos[,i]), ncol=2)-1)[,2] pheno.mat.dam[,(y+1)] <- geno.dat[,(i+1)] # (matrix(as.numeric(genos[,i]), ncol=2)-1)[,2] z <- z+2 y <- y+2 } pop.list <- c(rep(1, 200), rep(2, 200), rep(3, 200), rep(4, 200), rep(5, 200), rep(6, 200), rep(7, 200), rep(8, 200), rep(9, 200), rep(10, 200), rep(11, 200), rep(12, 200), rep(13, 200), rep(14, 200), rep(15, 200)) pheno.mat.dam <- cbind(pop.list, pheno.mat.dam) # use for sampling dams pheno.mat.sire <- cbind(pop.list, pheno.mat.sire) # use for sampling sires # now have a matrix of all inds to be used as sires (300 columns, 150 loci) and a matrix of one alllele for all inds to be used as dams (150 columns, 150 loci) and these are the same inds, so when choosing inds, must be sure to take diff ones for dams and sires dam.mat <- NULL sire.mat <- NULL offspring.pheno <- NULL sire.alleles.to.take <- seq(2, 300, by=2) # null list of alleles to take, i.e. all first allele per locus, start at 2 because first column is pop ID dam.alleles.to.take <- seq(2, 300, by=2) # null list of alleles to take, i.e. all first allele per locus, start at 2 because first column is pop ID for(i in 1:npops){ # go through each pop and make offspring (8 offspring per 15 sire-dam combinations) # choose 5 sires from each pop and mate with 3 dams each sires.to.sample <- sample(1:inds.per.pop, size=nsires, replace=FALSE) temp.sires <- pheno.mat.sire[pheno.mat.sire[,1]==i,][sires.to.sample,] # take only the rows in that pop and sample dams from them # sample dams, and make sure they're not the same individuals as the sires that were already sampled dams.to.sample <- sample((1:inds.per.pop)[-sires.to.sample], size= ndams, replace=FALSE) temp.dams <- pheno.mat.dam[pheno.mat.dam[,1]==i,][dams.to.sample,] # take only the rows in that pop and sample dams from them # MATE ONE SIRE WITH THREE DAMS, GO THROUGH FIVE SIRES # for this, want to take one allele from each parent, so new random alleles from the sire each time the sire is remated, and new random alleles from the dam each time the dam makes a new offspring # because I have made 15 distinct dams, I need to cycle through those fifteen, not the same three for every sire, but don't want all 15 to mate with one sire, so they iterate within the loop as well as by adding dam.it dam.it <- 0 for(j in 1:nsires){ # iterate through the 5 sires for(k in 1:(ndams/nsires)){ # iterate through the 15 dams (3 per sire), so from 1 to 3 here since I've made as many dams as there are for ALL sires, not just 1 sire, and the division will let me just go through the number of dams per 1 sire current.sire <- temp.sires[j,] current.dam <- temp.dams[(k+dam.it),] sire.alleles <- sire.alleles.to.take + round(runif(150)) # add 0 or 1 randomly to take each locus's first or second allele from the sire dam.alleles <- dam.alleles.to.take + round(runif(150)) # add 0 or 1 randomly to take each locus's first or second allele from the dam temp.offspring.pheno1 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) # add the pop id in then sum to get phenotype of the offspring sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno2 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno3 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno4 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno5 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno6 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno7 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) sire.alleles <- sire.alleles.to.take + round(runif(150)) dam.alleles <- dam.alleles.to.take + round(runif(150)) temp.offspring.pheno8 <- cbind(i, sum(current.dam[dam.alleles]) + sum(current.sire[sire.alleles])) offspring.pheno <- rbind( offspring.pheno, temp.offspring.pheno1, temp.offspring.pheno2, temp.offspring.pheno3, temp.offspring.pheno4, temp.offspring.pheno5, temp.offspring.pheno6, temp.offspring.pheno7, temp.offspring.pheno8) #print(c("pop", i, "sire", j, "dam", (k+dam.it))) } dam.it <- dam.it+3 } } phenotypes <- offspring.pheno # should be 1800 inds here, half will be culled below to end up with 900 inds dam.list <- rep(1:225, each=8) # because 8 offspring per one dame sire.list <- rep(1:75, each=24) # because 24 offspring per one sire (3 dams per sire) pre.unbalancing.final.phenotype <- cbind(phenotypes[,1], sire.list, dam.list, phenotypes[,2]) pre.unbalancing.final.phenotype <- as.data.frame(pre.unbalancing.final.phenotype) phenotypes.to.take <- sample(1:1800, size=900, replace=FALSE) # randomly sample to do the unbalanced part of the design, on avg will have 4 offspring per dam final.phenotypes <- pre.unbalancing.final.phenotype[phenotypes.to.take,] sorted.final.phenotypes <- final.phenotypes[order(final.phenotypes[,1], final.phenotypes[,2], final.phenotypes[,3]),] names(sorted.final.phenotypes) <- c("pop", "sire", "dam", "trait") simulated.qst.dat <- sorted.final.phenotypes # makes a data frame of pop list, sire list, dam list, and trait list write.csv(simulated.qst.dat, file="QstData_SireUnbalancedTest.csv", row.names=FALSE) # qst data sim.qst.dat <- read.csv("QstData_SireUnbalancedTest.csv") # fst data sim.fst.dat <- "FstData_SireUnbalancedTest.csv" answer <- qstfst.parboot(sim.fst.dat, sim.qst.dat, ndeme=15, nloci=100, AFLP=TRUE, breeding.design="half.sib.sire", nsim=1000, output="full") return(list(answer)) } # end function full.data <- NULL for(i in all.files){ answer <- nemo.qst(i, npops=15, ndams=15, nsires=5, inds.per.pop=200) # this function is created above row.of.data <- c(unlist(answer)) full.data <- rbind(full.data, row.of.data) write.csv(full.data, file="Qst_SireUnbalancedTest_Results.csv") # print and update the data after each nemo replicate is run }