dataesr/scientific-paragraphs-categorization huggingface dataset:
According to some recent discussions with automotive and aerospace specialists, there is a lack of engineers able to deal with the full process from control design to hardware implementation. This observation is also confirmed by the increasing desire of students in control system courses to learn how to implement algorithms directly on dedicated hardware. Based on this assessment, it has been decided to propose a simple and fast methodology for RCP based on the interface of a microcontroller directly with Matlab/Simulink by taking advantage of the graphical interface provided by the Microchip Technology MPLAB® device blocks for Simulink. This is important to note that unlike some existing setup  [1] , the objective is not to 'hide' and make totally transparent the code generation but on the contrary to make it accessible in order to tackle the problems that arise from this implementation.
In addition to the teaching benefit, the second objective is to fill the gap between convenient but expensive RCP platforms and complex but cheaper microcontroller tools. The developed methodology will speed up the implementation of advanced control algorithms on real hardware by removing the phase of coding on the target (see Figure  1 ). A dsPIC® Digital Signal Controllers (DSCs) and its dedicated MPLAB toolbox for Simulink has been used for this article but other manufacturer DSCs or Microcontroller Unit (MCU) may benefit this methodology whenever a dedicated toolbox exists. The goal of the article is to illustrate a methodology for real-time control regardless of the targeted architecture. For sake of simplicity, the example is based on a familiar DC motor, however the methods and tools used (software and hardware) can be adapted to other types of hardware.
Possible issues can be saturation of the command due to high frequency noise or dynamic not taken into account by the control model. Overflow and lacks of resolution can also be detected if fixed-point calculation are performed but not scaled appropriately. Fixed-point calculation can be used in critical steps where high speed execution is required. Section 5 provides further insight on fixed point scaling tools. Real-time experiments data can be sent to MATLAB/Simulink using the UART. The received logs can be used in simulation to compare an input sent both to the model and the real system.
Requirements Hardware The Microchip MCLV-2 board is targeted. It is equipped with the 16-bit dsPIC DSCs 33EP256MC506 Plug In Module (PIM) version using the dsPIC internal op-amps for current signal conditioning. The board drives the DC motor thanks to a H-bridge. Software Matlab/Simulink is used with the Embedded Coder and the fixed-point toolbox from MathWorks. The MPLAB device blocks for Simulink adds to Simulink the capability to target up to 270 Microchip microcontrollers (dsPIC, PIC32). Theses blocks rely on XC16 compiler and the MPLAB X IDE 2  to compile the generated code and program the board from the Simulink interface with a single 'Build' push button on top right of the simulink interface (see Figure  10 ). The compiled model has a discrete time solver and few dsPIC peripheral blocks.
Discrete step of 25µs or (40kHz control loop frequency) can be reached but floating-point calculation should be avoided in high rate task. Floating-point calculation can be used in lower rate tasks as illustrated by the D2 task in Figure  11. Matlab/Simulink provides a Fixed-point toolbox to help with the conversion of the floating-point model into a fixed-point equivalent. One method consists in logging values taken by each variable during a simulation using double datatype. Then for each variable, it is possible from the distribution histogram to choose the variable data length, which typically would be either 16 or 32 bits, and to select its scaling. Scaling: Simulink is not limited to floating point value, integers and the classical fixed point (noted Qx. xx) value within [-1 1] or [0 1] range.
Fire-related CO 2 fluxes We used two different satellite estimates of fire CO 2 emissions: the Global Fire Emissions Database version 4 (GFED4s) described in van der  Werf et al. (2017)  and the Copernicus Atmosphere Monitoring Service Global Fire Assimilation System (CMAS-GFAS;  Kaiser et al. , 2012). GFED4s has a spatial resolution of 0. 25 • with a monthly time step and provides data from 1997-2020. We note that starting from 2017, the GFED4s data are flagged as a beta version; i. e. starting 2017, fire emissions are derived from active fire detections instead of burned area. CAMS-GFAS covers the years 2003-2020 on a 0. 1 • horizontal grid. The source for both estimates is the MODIS satellite, but different variables and methods are used to derive the fire CO 2 emissions (for https://doi.
Further, years where both an IOD and an ENSO event occur were accounted for in both the IOD and ENSO categories and therefore double-counted. An additional limitation of our approach was that we compiled the occurrence of ENSO and IOD events from different sources based on the sea surface temperature. Observations of sea surface temperature prior to 1960 however are associated with large uncertainty given that they were mostly based on ship data (e. g. Deser et al. , 2010). In addition, the Southern Hemisphere tends to be less well observed, and spurious trends in reanalyses do occur (e. g. Hines et al. , 2000) , leading to an overall increased uncertainty in the sampling of data based on modes of variability. Overall, dry and wet extremes in precipitation led to the largest differences among the models (see "driest years" and "wettest years" in Fig.
A4 Nitrogen deposition and fertilization For the years from 1850 to 2014, the TRENDY models were forced with the historical nitrogen deposition database and then transitioned to the future RCP8. 5 nitrogen deposition databases for the years from 2015 to 2018. Details are available at https://esgf-node. llnl. gov/search/input4mips/. Nitrogen fertilizer input datasets are available via the N 2 O Model Intercomparison Project ("NMIP";  Tian et al. , 2018). NMIP assumes that the nitrogen input data remain unchanged in the https://doi. org/10. 5194/bg-18-5639-2021 Biogeosciences, 18, 5639-5668, 2021 Biogeosciences, 18, 5639-5668, years 2015 Biogeosciences, 18, 5639-5668, , 2016 Biogeosciences, 18, 5639-5668, , 2017 Biogeosciences, 18, 5639-5668, , and 2018. Manure is not included for the TRENDY simulations.
2, 16 The lack of ancient genomic data older than 15 kya  22  from Africa makes it difficult to address this issue from an ancient DNA perspective. However, neural networks (NNs) have been shown to be extremely powerful to disentangle such complex scenarios. 20 n the last few decades, the development of efficient and powerful computing infrastructure allowed us to gain substantial progress in the machine learning field, especially for computationally demanding algorithms such as NN  23, 24  and Bayesian methods. 25, 26 5] 27  However, NN requires a large amount of data as a training set. In some cases, this limitation can be overcome via the use of simulated data. Given that the modern tools allow for efficient simulation of large sets of synthetic genetic data,  28, 29  NN is already adopted in population genomics for interpretation of the genomic data in terms of underlying demography  20, 30, 31  and positive selection.
32, 33 owever, unlike classical approaches, it is still challenging to measure the significance of a prediction performed by NN given that it is a black-box approach. Approximate Bayesian computation (ABC) can be used to weigh the accuracy of a NN-based prediction from the data itself without knowing the maximum likelihood function. 20, 30, 34 However, ABC may face the ''curse of dimensionality'' problem when high dimensional input data or summary statistics are used. 35 It performs less efficiently when the harnessed summary statistics do not capture enough information. Here, we used NN to reduce the dimensionality of the original summary statistics and to produce highly informative secondary summary statistics, which is used as input by ABC to perform statistical analysis. Sequential Monte Carlo (SMC, also known as the particle filter method)  36  is used to recursively predict posterior distribution from a prior.
Our approach relies on an NN trained on simulated genetic data under the models being tested. However, it has three key improvements compared to other similar approaches. First, the use of the hdf5 41 data format and tensor flow  42  allows for extremely large training datasets. Second, the conventional NN approach is improved with ABC, which helps to provide statistical support for the NN prediction and to obtain posterior distribution for the model parameter values. Third, inspired by previous works,  38  we applied a modification of the SMC  36  approach to iterate the whole procedure. This algorithm improved the prediction accuracy substantially compared to previously implemented methods. 20, 43 We apply this method to test the three OOA models mentioned above.
Real data We have downloaded the high-coverage 1000 Genomes  44  vcf files produced by the Coriell Institute for Medical Research. We randomly selected five individuals to represent Africa, Europe, and East Asia originating at Yoruba from Ibadan, Nigeria (YRI), Utah residents with European origin (CEU), and Chinese Han from Beijing (CHB) populations (15 individuals in total). As an alternative dataset, we have also downloaded the high-coverage Human Genome Diversity Project (HGDP) vcf files  45  and randomly selected five Yoruba (YRI), five French (FRN), and five Han Chinese (HAN) individuals representing Africa, Europe, and East Asia (Table  S1 ). Unless mentioned otherwise, the results presented here were obtained on the first dataset. In order to avoid introducing any bias by the including only a subset of mixing archaic humans due to availability of such genomes and mixing ancient genome with the modern humans, we decided not to use any ancient genome.
Moreover, it is suggested that both Neanderthal and Denisova sequences, which are available, are distantly related with the introgressed populations,  46, 47  suggesting an even more complicated model. As our primary objective is with the OOA event and to give all archaic populations the same treatment (because African archaic populations are not yet sequenced), they are treated as ghost populations in our simulations. We treated each dataset independently and kept only bi-allelic single-nucleotide polymorphisms (SNPs) with genotype calls present in every individual and lifted the genomic positions to GRCh37 coordinates by using Picard tools. Next, we used two alternative filtering approaches: (1) filtering out genes and CpG islands (for more details, please see Mondal et al. , 2019  20  ) and (  2 ) applying a mappability mask coming from SNPable  13  for the 1000 Genomes dataset in Table  S2.
Filtering strategy 1 will be preferable to 2 in the case that the information of CpG islands and genes are available. In the absence of those information (for example non-human genetic data), our method can still reproduce similar result with filtering strategy 2. All the filtering was performed with vcftools and bcftools. 48, 49 The vcf file was converted to joint unfolded site frequency spectrum (SFS) via an inhouse code with scikit allel. 50 For unfolded SFS, we need to know ancestral allele and derived allele for the real data (for simulation, it is already known). We used 1000 Genome ancestral allele alignments of fasta files to polarize the alleles to ancestral and derived. When ancestral allele information is not present for a given SNP, we have removed that SNP from our analysis.
Genotype to site frequency spectrum The SFS from the three populations (Africa, Europe, and East Asia) was computed as a tridimensional tensor from the sequenced or simulated data and further transformed into an array to be used as input by the NN. SFS is the total number of segregating sites for a given derived allele count present in each population. SFSði; j; kÞ ¼ X n m¼1 ( 1; if s 1 ¼ i and s 2 ¼ j and s 3 ¼ k: 0; otherwise: Where i, j, and k are the numbers of derived alleles count per SNP in pop1, pop2, and pop3, respectively, and n is the total number of segregating SNPs. The whole SFS was represented as a row. We multiplied all the elements of the real SFS by a constant (frac) to make it comparable with the length of simulated regions if those do not match. For example, we multiplied the real SFS by 100/647 (or 0.
ABC-DL We have implemented an improved version of ABC-DL  20  (here onward, we call this implementation DL, and the implementation that additionally uses SMC [called DLS] is described below) by using state-of-the-art machine learning packages in python. We used TensorFlow with Keras backend  42  for building the NN and abc package for implementing ABC. 58 The use of hdf5 format  41  enabled us to analyze the whole dataset without loading into the memory. This allows us to train the NN on extremely large simulated datasets. Parameter estimation with DL Here, we describe parameter estimation by using NN and ABC. We ran a total of 60,000 different simulations, each producing 3,000 of 1 Mb regions (3 Gb [gigabase pair] in total, roughly equal to the length of the human genome). Every line of the NN input is one such simulation performed under a given demographic model with the columns representing SFS elements and the parameters used for that simulation are used as known output.
We ran parameter estimation by using this information and retrieve the parameters predicted on observed data for a given model. We used the known parameters as output for training the NN (y), and we used the SFS as input (x). Thus, we can think of the NN as a non-linear model for predicting the parameters from the SFS. We kept out 10,000 random lines for the testing dataset and ABC analysis, and the rest were used for training the NN. Both SFS and parameter values were normalized per column with MinMax scaler (from scikit-learn)  59  so that each data entry is within 0 and 1. We used four hidden layers of a dense NN (Figure  S1 ) with activation relu (from Keras package). These are basic building blocks for NNs. We used the linear layer (from Keras package) for the output layer with the same number of units as the number of parameters.
Although we have used other more classical approaches (i. e. , mean square error, stochastic gradient descent, etc. ), we found this combination to be better suited for our approach. The NN ran through the training dataset several times (epochs) to increase accuracy. We used EarlyStopping (from Keras package) on loss coming from validation dataset with the patient of 100. This stopped the epoch cycle in case there was no improvement for the last 100 epochs (meaning the NN reached a convergence for the current data). We used the ModelCheckpoint (from Keras package) of the lowest loss result on validation data, as the last epoch is not guaranteed to have the lowest loss on validation data. We also used ReduceLROnPlateau (from Keras package) of factor 0. 2 to reduce the learning rate if we reached minima for several epochs (ten by default).
Model selection with DL Here, we describe model selection by using NN and ABC. Unless stated otherwise, we simulated 2,000 simulations for each of the three demographic models tested (see full description of demographic models below). We simulated all the models for 3 Gb regions to make it equal for different approaches and finally scale the real data accordingly. This approach is preferable because we can train the NN only once for different length of real data. To test whether our scaling approach and the length of simulated region are not creating any biases, we also simulated an only 647 Mb region (equal to our filtering strategy 1) with the multiple of 25 Kb regions without using scaling in Table  S4. The resulting CSV files (one per model) are used together as input for model selection.
Model selection was repeated ten times both for DL and DLS. We found that if the results have high accuracy (posterior probability on observed data is >95% for the correct model), all the ten runs are essentially equal (which is expected). We used SFS as input (x) for the NN and the model category as output (y) and removed the parameters values because they are not needed for this step. We used MinMax scaler from sklearn  59  only on the SFS data as above, and the names of the models are converted to one-hot encoding by pandas. Categorical (from pandas package) and Keras. utils. to_categorical (from Keras package). After concatenating files coming from all the competing models, we shuffled the rows by a custom code. 60 We left out around 1,000 random rows per model to test the power of NN (as a testing dataset) and for ABC analysis and used the rest to train the NN (as a training dataset).
After the training was done, we used the testing dataset to predict models from the simulated SFS, which we then used to perform the cross-validation test by using ABC with the tolerance of 0. 033 (which converts to 100 samples) in case of three models and 0. 0066 (which converts to 100 samples) in case of 15 models via rejection (from abc package). We applied the model selection by abc. postpr (from abc package) to the real data. See a schematic representation in Figure  S2.
We used 10,000 simulations as a training dataset and 10,000 simulations for testing. The NN model is exactly as before (as used in DL, Figure  S1 ). To make it more efficient, we started with simulating a total length of 100 Mb (each simulated region being 1 Mb long), and then we increased the total length stepwise (i. e. , 0. 5, 1. 5, and 3 Gb). The priors for 100 Mb regions are the same as presented in Table  1. The final posterior (after convergence reached) of the run with 100 Mb is used as a prior for 0. 5 Gb simulation and so on. We multiplied the observed SFS by frac accordingly to scale it to the simulated region length. After the convergence was reached with 3 Gb in total, we finalized by running 50,000 training and 10,000 testing simulations with the DL method by using loclinear (from abc package) with the tolerance of 0.
Model selection with DLS Here, we describe model selection by using NN, ABC, and SMC together. In principle, we can directly use the final output of the parameter estimation procedure by DLS for every model and then use it for the ABC classification approach. However, this approach would be inefficient given that only one model is true for our real dataset, and thus spending considerable resources to optimize parameters for unlikely scenarios does not make sense. Instead, we used the output of 100 Mb parameter optimizations from the DLS approach as a prior to every model, and then we used the model selection strategy of DL, as mentioned before. In other words, we first optimized the parameters for each model class by using 100 Mb of simulated sequence and then compare the different models between each other.
ABC-RF We tested the real SFS against the three simulated models by using a similar ABC approach but with random forest  61  (here onward, we call this implementation RF) as an inferential tool implemented in the abcrf R package. 43, 62 First, we trained our model by using the bagging method applying the function abcrf, with no linear discriminant analysis, and 2,000 decision trees by using 1,000 simulations for each tested model. We then evaluated the performance of ABC-RF through a cross-validation dataset composed of 1,000 simulations for each tested model by using the function predict. abcrf. The same function and settings were used for inferring the best-supported model with the SFS obtained from real data described above. We performed parameter estimation for the most supported scenario applying regression as implemented in the re-gAbcrf model by using 1,000 decision trees.
We kept positions that (1) are bi-allelic SNPs, (2) pass the 1000 Genomes filters and have the value of the QD (quality by depth) parameter above two and (  3 ) have a missing rate below 10%. We phased and imputed the entire dataset by using Eagle version 2. 4. 1. 70 Next, we ran Relate on chromosome 1 for samples coming from the three focal populations. We used the GRCh38 recombination map, 1000 Genomes strict genomic mask, and a mutation rate of 1. 45 3 10 À8 per bp per generation. Next, we ran the effective population size estimation module of Relate for each population individually to obtain the effective population size trajectories and for population pairs to obtain the cross-coalescence rates. For each model, we simulated a region of the same length as chromosome 1 with uniform recombination together for 100 African, 100 European, and 100 East Asian individuals by using msprime.
Comparing mutation age distribution between the simulations and real data Relate estimates branch length in generations for the inferred trees and thus allows us to obtain tMRCA for any given mutation mapped to a specific tree branch. This value for a given mutation may differ between populations, reflecting the history of the spread of the mutation. A joined distribution of mutations' tMRCA in two populations may reflect the complex history and interactions between the two populations through time. Thus, we compared such two-dimensional tMRCA distributions obtained from the real genomes and from the genomes simulated under the The American Journal of Human Genetics 108, 2037-2051, November 4, 2021 2043 demographic models tested (Neanderthal, Denisova, and Africa archaic introgression with the above three models [BNDX, MNDX, and SNDX] parameters coming from Tables 2, S5, and S6, respectively) for each of the three population pairs (CEU-YRI, CHB-YRI, and CEU-CHB).
We first did a log10 transformation of the tMRCA values (Figure  S4 ) and then did a kernel density estimation for each dataset (real, BNDX, MNDX, and SNDX) and each pair of populations to obtain a matrix of a two-dimensional distribution of allele ages. For the density estimation, we used the kde2d function from the MASS R package setting n (number of grid points) to 100. Next, we subtracted such a matrix obtained for the real data from each of the simulation matrices. Together with the distribution of this difference, we report the root-meansquare deviation between the two matrices. RMSD ¼ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 1 N X N i¼1 d 2 i v u u t ; where d i is the difference between the value in the i th cells of the matrix for the simulated and real distribution and N is the number of cells (100 3 100).
ABC-DLS The general workflow for ABC-DLS (both for model selection and parameters estimation) includes the following steps. First, we simulated  29  multiple genetic datasets for each tested model by using demographic parameters sampled from a uniform distribution within prior ranges (Table  1 ). Next, we computed the SFS from these data and split the data into a training and a testing subset. We then trained the NN (implemented via TensorFlow with Keras backended  42  ) on the former dataset to either select between demographic models or to estimate the demographic parameters. The resulting NN is applied to the testing dataset as well as to the observed summary statistics data (see below as well as material and methods for more details). Next, we applied ABC to estimate support for the NN prediction on the observed data by comparing the NN prediction outcome between the observed data and the testing dataset (see material and methods, Figure  S2 , and also our previous paper  20  ).