BoPeng / simuPOP

A general-purpose forward-time population genetics simulation environment.
http://bopeng.github.io/simuPOP/
GNU General Public License v2.0
31 stars 12 forks source link

Cannot use frequency list to initialize beginFreq in trajectory #113

Closed marina-klemm closed 11 months ago

marina-klemm commented 1 year ago

Kia ora Bo Peng, I keep running into the same error when trying to run my simulation using my mtDNA frequencies file inside the beginFreq at my trajectory function. I have the frequency for 100 alleles and I'm running the simulation with 100 loci. However, whenever I try to define the trajectory, it says "Initial frequency should be provided for each locus (nLoci) or each locus at each subpopulation (nLoci * len(N))." Is there a way around it? My code follows attached in txt.

Additionally, is there a limit of generations or individuals that can be input into a trajectory? I verified that I cannot have a simulation with less than 80 generations, since that gives me the error "AttributeError: 'NoneType' object has no attribute 'func'". In my simulation, I start with 30,000 individuals and my population goes through a bottleneck of 40 within 10 generations. I found trajectory does not run with such a large number of individuals and perhaps with a narrow bottleneck like this. traj.func_error.txt

Thank you so very much for your time. Ngā mihi, Marina.

BoPeng commented 1 year ago

I get mtDNA_1.txt not found error when I tried to reproduce your problem.

marina-klemm commented 1 year ago

Hi Bo, Thank you for your reply. The file follows attached here. Thank you! Kind regards

Em seg., 27 de nov. de 2023 às 18:22, Bo @.***> escreveu:

I get mtDNA_1.txt not found error when I tried to reproduce your problem.

— Reply to this email directly, view it on GitHub https://github.com/BoPeng/simuPOP/issues/113#issuecomment-1827142845, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXYB3DJJ3DCDD5FQ5PF6ORDYGQPTDAVCNFSM6AAAAAA7YMTUJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRXGE2DEOBUGU . You are receiving this because you authored the thread.Message ID: @.***>

--

Marina Klemm she/her PhD in Biological Sciences

0.130066116932049 0.0894420970911519 0.0365202462650868 0.00871891398414421 0.0457264089847202 0.051094049265227 0.0843284207640962 0.0244838439696829 0.0548904445304925 0.0606503071243524 0.0290703200013599 0.0387361409626161 0.116682131626435 0.050716135067477 0.142033352306105 0.109905609402619 0.00495209681599519 0.0103232826601182 0.0203388456217867 0.037172698022545 0.00151577683959519 0.000328827862749063 0.0213600852578437 0.00959241506831641 0.00381032867909513 0.00891262321570067 0.00804801648127618 0.0190922624728045 0.0257809360763726 0.0824919880673782 0.00170353476845035 0.02061577908454 0.00111542534329108 0.000170959179165283 0.000191631333891332 3.22835735004083e-05 0.022833186524893 0.0168867635030492 0.00574921366946215 1.98397609158582e-05 0.0151805819323895 0.00107847232840108 0.00400576985887394 3.34808969172526e-06 0.0107918194976661 0.0195696857145993 6.19717117820552e-06 0.0149945101491454 0.000531775508786178 0.0135297873015044 2.92689451978075e-05 3.62186478494007e-05 6.36544051442264e-09 3.25336869435967e-06 6.94115358889259e-10 0.00171618308094852 0.000977558424820947 0.0136107192308002 0.000714356694861191 0.000167554176577607 0.00239951932040431 0.00141068626047619 0.00122726892753692 0.00284360955486043 2.88611279970082e-05 8.93033344894517e-09 0.00323397314686113 0.0216832092208119 0.00532860916954761 0.00285165734702765 0.000792433524182855 0.00175634852472115 0.0227135573788417 0.00363771371689393 0.00963694188781807 0.00249245515947116 0.000362970288089471 0.00617327199139884 0.0124939227146012 0.0113122528545172 0.00207350164380182 0.0135241206995208 0.0009370667964117 0.0101334581821649 0.00342112130584303 0.00311283847769427 0.00601803629742838 0.0141662074090561 0.000220882893464651 0.00445979613865707 0.00759916880896054 0.000826607237752723 0.00953610025805854 0.00639655580407841 0.00770549515478168 0.139309273269453 0.0240402667793628 0.0011711342206774 0.00867436610085125 0.00792440850576935 0.0178840944040212 0.0130194247356985 0.0124295653217451 0.0135518642166941 0.00760628362068351 0.00392602987244825 2.40337365183429e-05 0.00147574199252198 0.0105963923740135 0.00269031128494451 0.0292666321070082 0.000861876723339222 0.00174777701221232 7.71068176284027e-06 0.00304730398332708 0.00518487556098893

BoPeng commented 12 months ago

I notice that your formatted_list is a list of strings like

['0.130066116932049, 0', '0.0365202462650868, 0', '0.0457264089847202, 0', '0.0843284207640962, 0',

where the documentation says

        beginFreq
            The initial allele frequency of involved loci in all subpopulations.
            It can be a number (same frequency for all loci in all
            subpopulations), or a list of frequencies for each locus (same
            frequency in all subpopulations), or a list of frequencies for each
            locus in each subpopulation in the order of ``loc0_sp0``,
            ``loc1_sp0``, ..., ``loc0_sp1``, ``loc1_sp1``, ... and so on.

I am not sure how exactly you would like to initialize this parameter, but

https://github.com/BoPeng/simuPOP/blob/50f4776530cd2904196e56927000357da9a564b4/src/utils.py#L1365-L1377

is the code to process it.