Merge branch 'initialCounts' into dev
This commit is contained in:
commit
390af9c65a
2 changed files with 25 additions and 32 deletions
|
|
@ -877,38 +877,6 @@ greedyMix <- function(
|
|||
|
||||
# %----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# function logml = ...
|
||||
# initialCounts(partition, data, npops, rows, noalle, adjprior)
|
||||
|
||||
# nloci=size(data,2);
|
||||
# ninds = size(rows, 1);
|
||||
|
||||
# koot = rows(:,1) - rows(:,2) + 1;
|
||||
# maxSize = max(koot);
|
||||
|
||||
# counts = zeros(max(noalle),nloci,npops);
|
||||
# sumcounts = zeros(npops,nloci);
|
||||
# for i=1:npops
|
||||
# for j=1:nloci
|
||||
# havainnotLokuksessa = find(partition==i & data(:,j)>=0);
|
||||
# sumcounts(i,j) = length(havainnotLokuksessa);
|
||||
# for k=1:noalle(j)
|
||||
# alleleCode = k;
|
||||
# N_ijk = length(find(data(havainnotLokuksessa,j)==alleleCode));
|
||||
# counts(k,j,i) = N_ijk;
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# %initializeGammaln(ninds, maxSize, max(noalle));
|
||||
|
||||
# logml = laskeLoggis(counts, sumcounts, adjprior);
|
||||
|
||||
|
||||
# %-----------------------------------------------------------------------
|
||||
|
||||
|
||||
# function logml=computeLogml(counts, sumcounts, noalle, data, rowsFromInd)
|
||||
# nloci = size(counts,2);
|
||||
# npops = size(counts,3);
|
||||
|
|
|
|||
25
R/initialCounts.R
Normal file
25
R/initialCounts.R
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
initialCounts <- function(partition, data, npops, rows, noalle, adjprior) {
|
||||
nloci <- size(data, 2)
|
||||
ninds <- size(rows, 1)
|
||||
|
||||
koot <- rows[, 1] - rows[, 2] + 1
|
||||
maxSize <- max(koot)
|
||||
|
||||
counts <- zeros(max(noalle), nloci, npops)
|
||||
sumcounts <- zeros(npops, nloci)
|
||||
for (i in 1:npops) {
|
||||
for (j in 1:nloci) {
|
||||
havainnotLokuksessa <- find(partition == i & data[, j] >= 0)
|
||||
sumcounts[i, j] <- length(havainnotLokuksessa)
|
||||
for (k in 1:noalle[j]) {
|
||||
alleleCode <- k
|
||||
N_ijk <- length(
|
||||
find(data[havainnotLokuksessa, j] == alleleCode)
|
||||
)
|
||||
counts[k, j, i] <- N_ijk
|
||||
}
|
||||
}
|
||||
}
|
||||
logml <- laskeLoggis(counts, sumcounts, adjprior)
|
||||
return(logml)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue