38512d92a8682a62e73c5b9e86366888be374532,dragonn/interpret/ism.py,,in_silico_mutagenesis,#,15
Before Change
functor=get_logit_function(model,target_layer_idx)
/Ǘ. get the wildtype predictions (n,1)
wild_type_logits=np.asarray(get_logit(functor,X))
wild_type_logits=np.squeeze(wild_type_logits,axis=2)
/ǘ. expand the wt array to dimensions: (num_samples,1,sequence_length)
//Initialize mutants array to the same shape
output_dim=wild_type_logits.shape+X.shape[2:4]
wt_expanded=np.empty(output_dim)
mutants_expanded=np.empty(output_dim)
empty_onehot=np.zeros(output_dim[3])
/Ǚ. Iterate through all tasks, positions
for task_index in range(output_dim[0]):
for sample_index in range(output_dim[1]):
print("task:"+str(task_index)+" sample:"+str(sample_index))
//fill in wild type logit values into an array of dim (task,sequence_length,num_bases)
wt_logit_for_task_sample=wild_type_logits[task_index][sample_index]
wt_expanded[task_index][sample_index]=np.tile(wt_logit_for_task_sample,(output_dim[2],output_dim[3]))
//mutagenize each position
for base_pos in range(output_dim[2]):
//for each position, iterate through the 4 bases
for base_letter in range(output_dim[3]):
cur_base=np.copy(empty_onehot)
cur_base[base_letter]=1
Xtmp=np.copy(np.expand_dims(X[sample_index],axis=0))
Xtmp[0][0][base_pos]=cur_base
//get the logit of Xtmp
mutants_expanded[task_index][sample_index][base_pos][base_letter]=np.squeeze(get_logit(functor,Xtmp)[task_index])
//subtract wt_expanded from mutants_expanded
ism_vals=mutants_expanded-wt_expanded
//For each position subtract the mean ISM score for that position from each of the 4 values
ism_vals_mean=np.expand_dims(np.mean(ism_vals,axis=3),axis=3)
ism_vals_normed=ism_vals-ism_vals_mean
After Change
Xtmp=np.array(np.expand_dims(X[sample_index],axis=0))
Xtmp[0][0][base_pos]=cur_base
//get the logit of Xtmp
Xtmp_logit=np.squeeze(preact_function(Xtmp),axis=0)
mutants_expanded[sample_index][0][base_pos][base_letter]=Xtmp_logit[task_index]
//subtract wt_expanded from mutants_expanded
ism_vals=mutants_expanded-wt_expanded
//For each position subtract the mean ISM score for that position from each of the 4 values
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances Project Name: kundajelab/dragonn
Commit Name: 38512d92a8682a62e73c5b9e86366888be374532
Time: 2019-05-29
Author: annashcherbina@gmail.com
File Name: dragonn/interpret/ism.py
Class Name:
Method Name: in_silico_mutagenesis
Project Name: akanimax/pro_gan_pytorch
Commit Name: 68dab2a79a136a1b90181d44300c22b8b6145f52
Time: 2019-04-28
Author: akanimax@gmail.com
File Name: samples/demo.py
Class Name:
Method Name: get_image
Project Name: interactiveaudiolab/nussl
Commit Name: 2ffbfa3a6bd3b8de8e21a762489346054dcd9ccc
Time: 2020-03-12
Author: prem@u.northwestern.edu
File Name: nussl/separation/deep/deep_mask_estimation.py
Class Name: DeepMaskEstimation
Method Name: extract_features