Set the list of genes that can be perturbed and are to be included in perturbation graph
(self)
| 942 | self.gene2go = pickle.load(f) |
| 943 | |
| 944 | def set_pert_genes(self): |
| 945 | """ |
| 946 | Set the list of genes that can be perturbed and are to be included in |
| 947 | perturbation graph |
| 948 | """ |
| 949 | |
| 950 | if self.gene_set_path is not None: |
| 951 | # If gene set specified for perturbation graph, use that |
| 952 | path_ = self.gene_set_path |
| 953 | self.default_pert_graph = False |
| 954 | with open(path_, 'rb') as f: |
| 955 | essential_genes = pickle.load(f) |
| 956 | |
| 957 | elif self.default_pert_graph is False: |
| 958 | # Use a smaller perturbation graph |
| 959 | all_pert_genes = get_genes_from_perts(self.adata.obs['condition']) |
| 960 | essential_genes = list(self.adata.var['gene_name'].values) |
| 961 | essential_genes += all_pert_genes |
| 962 | |
| 963 | else: |
| 964 | # Otherwise, use a large set of genes to create perturbation graph |
| 965 | server_path = 'https://dataverse.harvard.edu/api/access/datafile/6934320' |
| 966 | path_ = os.path.join(self.data_path, |
| 967 | 'essential_all_data_pert_genes.pkl') |
| 968 | with open(path_, 'rb') as f: |
| 969 | essential_genes = pickle.load(f) |
| 970 | |
| 971 | gene2go = {i: self.gene2go[i] for i in essential_genes if i in self.gene2go} |
| 972 | |
| 973 | self.pert_names = np.unique(list(gene2go.keys())) |
| 974 | self.node_map_pert = {x: it for it, x in enumerate(self.pert_names)} |
| 975 | |
| 976 | def load(self, data_name = None, data_path = None): |
| 977 | if data_name in ['norman', 'adamson', 'dixit', |