SHARE
TWEET

Untitled

a guest Sep 16th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %load file
  2. load('diff_genes_across_clusters.mat')
  3.  
  4. %write a for loop that for each cluster...
  5. for cluster = 1:num_clusters
  6.     %sort the cells into those that belong in the cluster
  7.     cluster_cells = (cluster_labels==cluster);
  8.     %sort the cells into those that do NOT belong in the cluster
  9.     noncluster_cells = (cluster_labels~=cluster);
  10.     %initialize/reset data structures to store results for each gene
  11.     %for every cluster for each iteration of the for loop
  12.     cluster_genes=[];
  13.     cluster_pvalues_per_gene=[];
  14.     gene_counter=0;
  15.    
  16.     %for every gene...
  17.     for gene = 1:num_genes
  18.     %get the gene expression values for cells in cluster 1
  19.         expr_cluster=A_log(cluster_cells,gene);
  20.     %get the gene expression values for cells NOT in cluster 1
  21.         expr_noncluster=A_log(noncluster_cells,gene);
  22.    
  23.     %check for differential gene expression between cells in and out
  24.     %of cluster 1  
  25.         [~,p] = ttest2(expr_cluster,expr_noncluster,'Vartype','unequal');      
  26.    
  27.     %store results only if...
  28.    
  29.     %1. p-value from t-test is significant...
  30.         if p<threshold
  31.           %AND 2. mean gene expression is higher in cells in cluster 1 vs noncluster 1
  32.               if mean(expr_cluster)>mean(expr_noncluster)
  33.               %count the gene
  34.                   gene_counter=gene_counter+1;
  35.               %remember the gene by its index number
  36.                   cluster1_genes(gene_counter)=gene;
  37.               %remember p-value for the gene
  38.                   cluster1_pvalues_per_gene(gene_counter)=p;
  39.               end
  40.         end
  41.     end
  42.  
  43.     %store the information for each cluster in a data structure called ge_clusters
  44.    
  45.     %get the number of the cluster
  46.     ge_clusters(cluster).name = cluster;
  47.     %get the indices of the differentially highly expressed genes for the cluster
  48.     ge_clusters(cluster).genes = cluster_genes;
  49.     %get the p-values of the differentially highly expressed genes for the cluster
  50.     ge_clusters(cluster).pvalues = cluster_pvalues_per_gene;
  51. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top