Removed global variables from argument lists

This commit is contained in:
Waldir Leoncio 2020-11-19 14:29:37 +01:00
parent 13446958aa
commit 19e212b137
15 changed files with 33 additions and 88 deletions

View file

@ -5,13 +5,9 @@
#' `tietue`should contain the following elements: PARTITION, COUNTS, SUMCOUNTS,
#' alleleCodes, adjprior, popnames, rowsFromInd, data, npops, noalle
#' @param tietue tietue
#' @param PARTITION PARTITION
#' @param COUNTS COUNTS
#' @param SUMCOUNTS SUMCOUNTS
#' @importFrom methods is
#' @export
admix1 <- function(tietue, PARTITION = matrix(NA, 0, 0),
COUNTS = matrix(NA, 0, 0), SUMCOUNTS = NA) {
admix1 <- function(tietue) {
if (!is.list(tietue)) {
message('Load mixture result file. These are the files in this directory:')
print(list.files())
@ -270,7 +266,7 @@ admix1 <- function(tietue, PARTITION = matrix(NA, 0, 0),
for (level in 1:n_missing_levels[pop]) {
potential_inds_in_this_pop_and_level <-
potential_inds_in_this_pop_and_level <-
find(
PARTITION == pop & missing_level_partition == level &
likelihood > 3

View file

@ -2,11 +2,8 @@
#' @description Lisää a priori jokaista alleelia joka populaation joka lokukseen
#' j 1/noalle(j) verran.
#' @param noalle noalle
#' @param COUNTS counts
#' @param SUMCOUNTS sumcounts
#' @export
computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
SUMCOUNTS = NA) {
computeAllFreqs2 <- function (noalle) {
max_noalle <- size(COUNTS, 1)
nloci <- size(COUNTS,2)

View file

@ -1,17 +1,15 @@
#' @title Compute Personal Freqs
#' @description Laskee npops*(rowsFromInd*nloci) taulukon, jonka kutakin
#' saraketta vastaa yksilön ind alleeli. Eri rivit ovat alleelin
#' alkuperäfrekvenssit eri populaatioissa. Jos yksilölt?puuttuu jokin alleeli,
#' alkuperäfrekvenssit eri populaatioissa. Jos yksilölt?puuttuu jokin alleeli,
#' niin vastaavaan kohtaa tulee sarake ykkösi?
#' @param ind ind
#' @param data data
#' @param allFreqs allFreqs
#' @param rowsFromInd rowsFromInd
#' @param COUNTS COUNTS
#' @export
computePersonalAllFreqs <- function(ind, data, allFreqs, rowsFromInd,
COUNTS = matrix(0)) {
computePersonalAllFreqs <- function(ind, data, allFreqs, rowsFromInd) {
nloci <- ifelse(is.na(dim(COUNTS)[2]), 1, dim(COUNTS)[2])
npops <- ifelse(is.na(dim(COUNTS)[3]), 1, dim(COUNTS)[3])

View file

@ -7,11 +7,8 @@
#' @param omaFreqs own Freqs?
#' @param osuusTaulu Percentage table?
#' @param logml log maximum likelihood
#' @param COUNTS COUNTS
#' @export
laskeMuutokset4 <- function (
osuus, osuusTaulu, omaFreqs, logml, COUNTS = matrix(0)
) {
laskeMuutokset4 <- function (osuus, osuusTaulu, omaFreqs, logml) {
npops <- ifelse(is.na(dim(COUNTS)[3]), 1, dim(COUNTS)[3])
notEmpty <- which(osuusTaulu > 0.005)
muutokset <- zeros(npops)

View file

@ -5,13 +5,8 @@
#' @param npops npops
#' @param rowsFromInd rowsFromInd
#' @param alaraja alaraja
#' @param PARTITION PARTITION
#' @param COUNTS COUNTS
#' @param SUMCOUNTS SUMCOUNTS
#' @export
poistaLiianPienet <- function (npops, rowsFromInd, alaraja,
PARTITION = matrix(NA, 0, 0), COUNTS = matrix(NA, 0, 0),
SUMCOUNTS = NA) {
poistaLiianPienet <- function (npops, rowsFromInd, alaraja) {
popSize <- zeros(1,npops)
if (npops > 0) {
for (i in 1:npops) {

View file

@ -2,10 +2,9 @@
#' @description Lisää jokaista alleelia joka populaation joka lokukseen j1/noalle(j) verran. Näin saatuja counts:eja vastaavista Dirichlet-jakaumista simuloidaan arvot populaatioiden alleelifrekvensseille.
#' Add each allele to each locus in each population by j 1 / noalle(j). The Dirichlet distributions corresponding to the counts thus obtained simulate values for the allele frequencies of the populations.
#' @param noalle noalle
#' @param COUNTS COUNTS
#' @export
simulateAllFreqs <- function(noalle, COUNTS = matrix(NA, 0, 0)) {
simulateAllFreqs <- function(noalle) {
max_noalle <- size(COUNTS, 1)
nloci <- size(COUNTS, 2)
npops <- size(COUNTS, 3)

View file

@ -3,9 +3,8 @@
#' @param osuusTaulu Percentage table?
#' @param osuus percentage?
#' @param indeksi index
#' @param COUNTS counts
#' @export
suoritaMuutos <- function (osuusTaulu, osuus, indeksi, COUNTS = matrix(0)) {
suoritaMuutos <- function (osuusTaulu, osuus, indeksi) {
npops <- ifelse(is.na(dim(COUNTS)[3]), 1, dim(COUNTS)[3])
i1 <- indeksi %% npops

View file

@ -1,9 +1,9 @@
viewPartition <- function(osuudet, popnames, COUNTS = matrix(0, 0, 0)) {
viewPartition <- function(osuudet, popnames) {
npops <- size(COUNTS, 3)
nind <- size(osuudet,1)
# TODO: translate if necessary. Remove if this function won't be used
# TODO: translate if necessary. Remove if this function won't be used
# disp(['Number of populations: ' num2str(npops)]);
# if npops>30
# disp(' ');
@ -12,27 +12,27 @@ viewPartition <- function(osuudet, popnames, COUNTS = matrix(0, 0, 0)) {
# disp(' ');
# return;
# end
# varit = givecolors(npops);
# korkeinviiva = 1.05;
# pieninarvo = -korkeinviiva;
# h0 = figure;
# set(h0, 'NumberTitle', 'off'); %image_figure; %Muutettu
# tiedot.popnames = popnames;
# tiedot.info = osuudet;
# set(h0,'UserData',tiedot);
# set(gca, 'Xlim', [-.5 ,nind+.5], 'YLim', [pieninarvo ,korkeinviiva], ...
# 'XTick', [], 'XTickLabel', [], 'YTick', [], 'YTickLabel', []);
# for i=1:nind
# if any(osuudet(i,:)>0)
# cumOsuudet = cumsum(osuudet(i,:));
# % Pylv<6C><76>n piirt<72>minen
# for j=1:npops
# if j==1
@ -50,21 +50,21 @@ viewPartition <- function(osuudet, popnames, COUNTS = matrix(0, 0, 0)) {
# end
# end
# end
# if ~isempty(popnames)
# npops = size(popnames,1);
# for i=1:npops
# firstInd = popnames{i,2};
# line([firstInd-1, firstInd-1], [0,1], 'Color', 'k'); %Populaatioiden rajat
# if i<npops
# x_paikka = popnames{i,2}-1+(popnames{i+1,2}-popnames{i,2})/2;
# else
# x_paikka = popnames{i,2}-1+(nind+1-popnames{i,2})/2;
# end
# korkeuskerroin = pieninarvo / -0.2;
# suhdekerroin = npops/6;
# for letter_num = 1:length(popnames{i,1}{1})
@ -105,7 +105,7 @@ giveColors <- function(n) {
0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0.4, 0.4, 0, 0.4, 0,
0.4, 0, 0.4, 0.4, 0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0.2,
0.2, 0, 0.2, 0, 0.2, 0, 0.2, 0.2, 0.8, 0, 0, 0, 0.8, 0,
0, 0, 0.8, 0.8, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0.8,
0, 0, 0.8, 0.8, 0.8, 0, 0.8, 0, 0.8, 0, 0.8, 0.8,
0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 0.6, 0.6, 0, 0.6, 0,
0.6, 0, 0.6, 0.6, 0.6, 0.2, 0.4, 0.2, 0.4, 0.8, 0.8,
0.4, 0.2, 0, 0.6, 0.2, 0.2, 0.8, 0.6, 0.5, 0.2, 0.1,