Code
library(data.table)
library(glmnet)
library(glue)
library(tidyverse)
Saideep Gona
November 16, 2023
X_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/HG00096.txt"
X <- as.matrix(data.table::fread(X_path))
glmnet_model_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/elastic_net/trained_eln_RNAseq_NI_from_HDF5_mean_log.linear.rds"
glmnet_model <- readRDS(glmnet_model_path)
glmnet_predictions <- predict(glmnet_model, X, s = "lambda.min", type="response")
write
function (x, file = "data", ncolumns = if (is.character(x)) 1 else 5,
append = FALSE, sep = " ")
cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"),
append = append)
<bytecode: 0x5641f3d9f930>
<environment: namespace:base>
# inds <- read_file("/beagle3/haky/users/saideep/github_repos/Daily-Blog-Sai/posts/2023-11-16-linearization/individuals.txt")
# inds <- gsub("\n", "", inds)
# inds <- strsplit(inds,split="\t")
# linear_dir <- "/beagle3/haky/users/saideep/projects/aracena_modeling/linearization"
# for (ind in inds[[1]]) {
# X_path <- glue("/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/{ind}.txt")
# print(ind)
# if (file.exists(X_path)) {
# X <- as.matrix(data.table::fread(X_path))
# glmnet_model_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/elastic_net/trained_eln_RNAseq_NI_from_HDF5_mean_log.linear.rds"
# glmnet_model <- readRDS(glmnet_model_path)
# glmnet_predictions <- as.data.frame(predict(glmnet_model, X, s = "lambda.min", type="response"))
# write_delim(glmnet_predictions, glue("/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/{ind}_preds.txt"), delim = "\t")
# } else {
# print(glue({"{ind} missing"}))
# }
# }
---
title: "predict_for_linearization"
author: "Saideep Gona"
date: "2023-11-16"
format:
html:
code-fold: true
code-summary: "Show the code"
execute:
freeze: true
warning: false
---
```{r}
library(data.table)
library(glmnet)
library(glue)
library(tidyverse)
```
```{r}
X_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/HG00096.txt"
X <- as.matrix(data.table::fread(X_path))
glmnet_model_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/elastic_net/trained_eln_RNAseq_NI_from_HDF5_mean_log.linear.rds"
glmnet_model <- readRDS(glmnet_model_path)
glmnet_predictions <- predict(glmnet_model, X, s = "lambda.min", type="response")
write
```
```{r}
# inds <- read_file("/beagle3/haky/users/saideep/github_repos/Daily-Blog-Sai/posts/2023-11-16-linearization/individuals.txt")
# inds <- gsub("\n", "", inds)
# inds <- strsplit(inds,split="\t")
# linear_dir <- "/beagle3/haky/users/saideep/projects/aracena_modeling/linearization"
# for (ind in inds[[1]]) {
# X_path <- glue("/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/{ind}.txt")
# print(ind)
# if (file.exists(X_path)) {
# X <- as.matrix(data.table::fread(X_path))
# glmnet_model_path <- "/beagle3/haky/users/saideep/projects/aracena_modeling/elastic_net/trained_eln_RNAseq_NI_from_HDF5_mean_log.linear.rds"
# glmnet_model <- readRDS(glmnet_model_path)
# glmnet_predictions <- as.data.frame(predict(glmnet_model, X, s = "lambda.min", type="response"))
# write_delim(glmnet_predictions, glue("/beagle3/haky/users/saideep/projects/aracena_modeling/linearization/{ind}_preds.txt"), delim = "\t")
# } else {
# print(glue({"{ind} missing"}))
# }
# }
```