minwoosun commited on
Commit
e2972d3
·
verified ·
1 Parent(s): d1e7e62

app.py allow for default dataset

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -40,7 +40,7 @@ def load_and_predict_with_classifier(x, model_path, output_path, save):
40
  return y_pred
41
 
42
 
43
- def main(input_file_path, species):
44
 
45
  # Get the current working directory
46
  current_working_directory = os.getcwd()
@@ -64,6 +64,15 @@ def main(input_file_path, species):
64
  # Add the directory to the Python path
65
  sys.path.append(new_directory)
66
 
 
 
 
 
 
 
 
 
 
67
 
68
  ##############
69
  # UCE #
@@ -223,8 +232,11 @@ if __name__ == "__main__":
223
  )
224
 
225
  # Define Gradio inputs and outputs
226
- file_input = gr.File(label="Upload a .h5ad single cell gene expression file")
227
- species_input = gr.Dropdown(choices=["human", "mouse"], label="Select species")
 
 
 
228
  run_button = gr.Button("Run")
229
 
230
  # Arrange UMAP plot and file output side by side
@@ -236,7 +248,7 @@ if __name__ == "__main__":
236
  # Add the components and link to the function
237
  run_button.click(
238
  fn=main,
239
- inputs=[file_input, species_input],
240
  outputs=[image_output, file_output, pred_output]
241
  )
242
 
 
40
  return y_pred
41
 
42
 
43
+ def main(input_file_path, species, default_dataset):
44
 
45
  # Get the current working directory
46
  current_working_directory = os.getcwd()
 
64
  # Add the directory to the Python path
65
  sys.path.append(new_directory)
66
 
67
+ # Set default dataset path
68
+ default_dataset_1_path = hf_hub_download(repo_id="minwoosun/uce-misc", filename="100_pbmcs_proc_subset.h5ad")
69
+ default_dataset_2_path = hf_hub_download(repo_id="minwoosun/uce-misc", filename="1k_pbmcs_proc_subset.h5ad")
70
+
71
+ # If the user selects a default dataset, use that instead of the uploaded file
72
+ if default_dataset == "Default Dataset 1: PBMC 100 cells":
73
+ input_file_path = default_dataset_1_path
74
+ elif default_dataset == "Default Dataset 2: PBMC 1000 cells":
75
+ input_file_path = default_dataset_2_path
76
 
77
  ##############
78
  # UCE #
 
232
  )
233
 
234
  # Define Gradio inputs and outputs
235
+ file_input = gr.File(label="Upload a .h5ad single cell gene expression file or select a default dataset below")
236
+ # species_input = gr.Dropdown(choices=["human", "mouse"], label="Select species")
237
+ with gr.Row():
238
+ species_input = gr.Dropdown(choices=["human", "mouse"], label="Select species")
239
+ default_dataset_input = gr.Dropdown(choices=["None", "PBMC 100 cells", "PBMC 1000 cells"], label="Select default dataset")
240
  run_button = gr.Button("Run")
241
 
242
  # Arrange UMAP plot and file output side by side
 
248
  # Add the components and link to the function
249
  run_button.click(
250
  fn=main,
251
+ inputs=[file_input, species_input, default_dataset_input],
252
  outputs=[image_output, file_output, pred_output]
253
  )
254