Sampling distriubtions
Closed this issue · 7 comments
Sorry for all the Issues, but this should be the last one for a while:
Is there an efficient manner to sample the latent space? I'm currently just randomly sampling the range of min/max for each feature, and having the decoder give the proper representation for that latent feature set, but not sure if thats the best route.
EDIT: To clarify, I have a classifier that can distinguish two populations based on rnaseq data. I would like to iteratively go through each gene in my model and see what happens when it is changed/lowered to a specific range. To do this, I'd like to sample the target distribution (for that given gene; likely just a 1sigma interval of 'normal' expression) and then run my classifier on the backend. Given the non-linear dependency of all the other genes on the target gene, the idea is to just randomly sample the latent space(and the learned distributions for each gene), and just select those vectors whose values meet my 1sigma criterion (on a per-gene basis, and hope that the representations of the other genes "respond" to the change in expression on my target gene).
Is there an efficient manner to sample the latent space? I'm currently just randomly sampling the range of min/max for each feature, and having the decoder give the proper representation for that latent feature set, but not sure if thats the best route.
We haven't done extensive sampling, but to me, the approach outlined above sounds like the way to go!
Is the goal to see which latent space features impact your genes of interest? If so, you may be able to short circuit the sampling step and look directly at the genes' connectivity in the decoder weight matrix. I can also imagine a scenario in which you are interested in what the distribution of samples looks like when a specific gene's expression is below a certain threshold. In that case, randomly sampling the latent space and rejecting all output when the gene of interest violates this threshold could be an interesting experiment.
It may also be worthwhile to checkout some of our recent work here: https://github.com/greenelab/BioBombe
Depending on goals and what your classifier is aiming to separate, the size of the latent space may be an important consideration!
Is the goal to see which latent space features impact your genes of interest?
Perhaps, but this may be looking at things a little differently than I was originally thinking. As you mentioned, we'd like to see what happens when you 'lower' the expression of a specific gene from one level to another, and what happens to the other genes in 'response'. As you're aware, we can just lower the genes manually without compensating the expression of our other genes in the vector, so we figured that random sampling the latent space and only keeping those that have our gene within a specific range would be a good approximation.
I will definitely look at the biobombe project--looks fantastic!
I'm attempting to sample the latent space with the following code:
NUM_SAMPLED_VECTORS = 1000
sampled_latent = []
maxs = encoded_rnaseq_df.max(axis=0).values.tolist()
# Sample 1000 vectors
for x in range(NUM_SAMPLED_VECTORS):
temp = []
for i,z in enumerate(maxs):
temp.append(uniform(0, z))
sampled_latent.append(temp)
sampled_latent_df = pd.DataFrame(sampled_latent)
sampled_pred_vectors = pd.DataFrame(decoder.predict_on_batch(sampled_latent_df))
However, I'm noticing that the sampled values are very, very small (min values ~10^-32, max values ~10^-22). Any ideas why?
Hi--don't mean to be a bother, but just wanted to ping this and see if you have any ideas on my comment above. When I randomly sample the latent spaces for each node, the outputs are ~10^-30 smaller than I would expect (e.g. roughly ~10^-1).
We haven't done extensive analyses on the generative aspects of Tybalt, so I don't know for sure. But if I had to guess, I'd say the model doesn't do well when all latent space features are sampled. I'd recommend isolating a few (maybe even one) and sampling this while fixing the others to represent a true sample. Sorry I don't have a more satisfying answer!
@gwaygenomics Thanks--sorry for pestering so much! I hadn't thought to try and 'fix' all but one latent variable--I figured that there should be some relationship between the latent variables, such that you explicitly couldn't do that. I'll try that from now on, and thanks for all the fantastic work here.
There should be a relationship between the latent variables to an extent. I also have a similar trepidation about that approach, but I'd love to hear how it works out. If the representation is sufficiently disentangled, perhaps it is ok 🤞 !