-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self-attribution from model #24
Comments
If what you're after is P(Source | ST) from the 'genotype distribution' part of the model (asymmetric island or dirichlet) then you can do this by using the likelihood returned by
Code: library(islandR)
library(tidyverse)
st = st_fit(formula = Source ~ ST,
non_primary = "Human",
data = manawatu,
method="island",
sequences = ~ ASP + GLN + GLT + GLY + PGM + TKT + UNC)
prior <- tibble(source = setdiff(unique(manawatu$Source), "Human"),
prior = 1/4)
exp_sum_log <- function(x) { y = x - max(x); exp(y)/sum(exp(y)) }
st |> as.data.frame() |>
left_join(prior) |>
mutate(log_pp = log(prior) + log_p) |>
group_by(type, iteration) |>
mutate(posterior = exp_sum_log(log_pp)) |>
select(type, iteration, posterior) |
Note that this is not including the 'attribution' part of the model, which infers the mixing (here the fixed prior) of the sources. Other SA models may be utilising that 'inferred mixing' when doing self attribution. This might be particularly important for imbalanced sources, though you may be able to incorporate that via the prior above. |
See 22e3215 |
Hi,
is there a way to get P of assignments of isolates to their own clusters? I.e., self-attribution results to assess the model reliability?
Thank you,
Domenico
The text was updated successfully, but these errors were encountered: