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: 5
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: kundajelab/dragonn
Commit Name: 172e1c71ff73c351b195c47ea6a89a24cc83e259
Time: 2019-07-10
Author: annashcherbina@gmail.com
File Name: dragonn/interpret/ism.py
Class Name:
Method Name: in_silico_mutagenesis
Project Name: kundajelab/dragonn
Commit Name: 4d3ecb451fc1ea0035847f71b003b403f0ffce72
Time: 2019-07-06
Author: annashcherbina@gmail.com
File Name: dragonn/vis/__init__.py
Class Name:
Method Name: plot_ism