{"metadata":{"kernelspec":{"name":"ir","display_name":"R","language":"R"},"language_info":{"name":"R","codemirror_mode":"r","pygments_lexer":"r","mimetype":"text/x-r-source","file_extension":".r","version":"4.0.5"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Beside the resources from the organizers, here are some resources that can help get you started:\n* https://www.neonscience.org/resources/learning-hub/tutorials/hdf5-intro-r\n* https://www.bioconductor.org/packages/devel/bioc/vignettes/rhdf5/inst/doc/rhdf5.html","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"# Install rhdf5 package (only need to run if not already installed)\n#install.packages(\"BiocManager\")\n#BiocManager::install(\"rhdf5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:47.969144Z","iopub.execute_input":"2022-09-15T20:23:47.971199Z","iopub.status.idle":"2022-09-15T20:23:48.116516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Call the R HDF5 Library\nlibrary(\"rhdf5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:48.118761Z","iopub.execute_input":"2022-09-15T20:23:48.155870Z","iopub.status.idle":"2022-09-15T20:23:48.399878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"List the objects within the file to find the data group you want to read:","metadata":{}},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/train_cite_targets.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:48.403737Z","iopub.execute_input":"2022-09-15T20:23:48.405847Z","iopub.status.idle":"2022-09-15T20:23:48.474109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/train_cite_inputs.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:48.477928Z","iopub.execute_input":"2022-09-15T20:23:48.479502Z","iopub.status.idle":"2022-09-15T20:23:49.166427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/test_cite_inputs.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:49.169026Z","iopub.execute_input":"2022-09-15T20:23:49.170444Z","iopub.status.idle":"2022-09-15T20:23:49.653383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/train_multi_targets.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:49.655727Z","iopub.execute_input":"2022-09-15T20:23:49.657132Z","iopub.status.idle":"2022-09-15T20:23:50.513160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/train_multi_inputs.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:50.515431Z","iopub.execute_input":"2022-09-15T20:23:50.516764Z","iopub.status.idle":"2022-09-15T20:23:55.284063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5ls(\"../input/open-problems-multimodal/test_multi_inputs.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:55.286465Z","iopub.execute_input":"2022-09-15T20:23:55.287832Z","iopub.status.idle":"2022-09-15T20:23:57.688588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata <- h5read(\"../input/open-problems-multimodal/train_cite_targets.h5\", '/train_cite_targets/axis0')\nunique(mydata)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:57.692051Z","iopub.execute_input":"2022-09-15T20:23:57.693720Z","iopub.status.idle":"2022-09-15T20:23:57.787807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata_axis1 <- h5read(\"../input/open-problems-multimodal/train_cite_targets.h5\", '/train_cite_targets/axis1')\nhead(mydata_axis1)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:57.790094Z","iopub.execute_input":"2022-09-15T20:23:57.791398Z","iopub.status.idle":"2022-09-15T20:23:57.852385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata_block0_items <- h5read(\"../input/open-problems-multimodal/train_cite_targets.h5\", '/train_cite_targets/block0_items')\nunique(mydata_block0_items)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:57.854685Z","iopub.execute_input":"2022-09-15T20:23:57.856017Z","iopub.status.idle":"2022-09-15T20:23:57.900696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata_block0_values <- h5read(\"../input/open-problems-multimodal/train_cite_targets.h5\", '/train_cite_targets/block0_values')\nhead(mydata_block0_values)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:57.902981Z","iopub.execute_input":"2022-09-15T20:23:57.904323Z","iopub.status.idle":"2022-09-15T20:23:58.710844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"metadata <- read.csv('../input/open-problems-multimodal/metadata.csv')\nlibrary(dplyr)\nhead(metadata)\nna_cells<-nrow(is.na(metadata$cell_id))\nna_cells\n\nduplicates <- nrow(duplicated(metadata$cell_id))\nduplicates","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:58.713524Z","iopub.execute_input":"2022-09-15T20:23:58.714885Z","iopub.status.idle":"2022-09-15T20:23:59.696859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"summary(metadata)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:59.699473Z","iopub.execute_input":"2022-09-15T20:23:59.700915Z","iopub.status.idle":"2022-09-15T20:23:59.767368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique(metadata$technology)\nunique(metadata$cell_type)\nunique(metadata$day)","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:59.769775Z","iopub.execute_input":"2022-09-15T20:23:59.771151Z","iopub.status.idle":"2022-09-15T20:23:59.811314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"loadhdf5data <- function(h5File) {\n\nlisting <- h5ls(h5File)\n# Find all data nodes, values are stored in *_values and corresponding column\n# titles in *_items\ndata_nodes <- grep(\"_values\", listing$name)\nname_nodes <- grep(\"_items\", listing$name)\n\ndata_paths = paste(listing$group[data_nodes], listing$name[data_nodes], sep = \"/\")\nname_paths = paste(listing$group[name_nodes], listing$name[name_nodes], sep = \"/\")\n\ncolumns = list()\nfor (idx in seq(data_paths)) {\n  data <- data.frame(t(h5read(h5File, data_paths[idx])))\n  names <- t(h5read(h5File, name_paths[idx]))\n  entry <- data.frame(data)\n  colnames(entry) <- names\n  columns <- append(columns, entry)\n}\n\ndata <- data.frame(columns)\n\nreturn(data)\n}\n\n","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:59.813737Z","iopub.execute_input":"2022-09-15T20:23:59.815106Z","iopub.status.idle":"2022-09-15T20:23:59.828390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:25:28.067437Z","iopub.execute_input":"2022-09-15T20:25:28.070281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = loadhdf5data(\"../input/open-problems-multimodal/test_cite_inputs_day_2_donor_27678.h5\")\ndata","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:23:59.830904Z","iopub.execute_input":"2022-09-15T20:23:59.832339Z","iopub.status.idle":"2022-09-15T20:24:18.676842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = loadhdf5data(\"../input/open-problems-multimodal/train_cite_targets.h5\")\ndata","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:24:18.679339Z","iopub.execute_input":"2022-09-15T20:24:18.680779Z","iopub.status.idle":"2022-09-15T20:24:19.905883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sessionInfo()","metadata":{"execution":{"iopub.status.busy":"2022-09-15T20:24:19.908565Z","iopub.execute_input":"2022-09-15T20:24:19.910121Z","iopub.status.idle":"2022-09-15T20:24:19.952951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}