Skip to content

Commit

Permalink
minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
snaketron committed Mar 23, 2024
1 parent 1bbb804 commit 8f96632
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 146 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: IgGeneUsage
Type: Package
Title: Differential gene usage in immune repertoires
Version: 1.17.14
Version: 1.17.15
Authors@R:
person(given = "Simo",
family = "Kitanovski",
Expand Down Expand Up @@ -33,8 +33,7 @@ Suggests:
ggplot2,
ggforce,
gridExtra,
ggrepel,
MASS
ggrepel
LinkingTo:
BH (>= 1.66.0),
Rcpp (>= 0.12.0),
Expand Down
28 changes: 14 additions & 14 deletions inst/stan/dgu.stan
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ data {
int<lower=0> N_gene; // gene
int<lower=0> N_individual; // number of individuals
int<lower=0> N_condition; // number of conditions
array[N_individual] int N; // number of tries (repertoire size)
array[N_gene, N_individual] int Y; // number of heads for each coin
array[N_individual] int condition_id; // id of conditions
array[N_individual] int individual_id; // id of replicate
array [N_individual] int N; // number of tries (repertoire size)
array [N_gene, N_individual] int Y; // number of heads for each coin
array [N_individual] int condition_id; // id of conditions
array [N_individual] int individual_id; // id of replicate
}

transformed data {
// convert int N -> real N fo convenient division
// in generated quantities block
real Nr [N_individual];
array [N_individual] real Nr;
Nr = N;
}

Expand All @@ -55,14 +55,14 @@ parameters {
vector <lower=0> [N_condition] sigma_condition;
vector <lower=0> [N_condition] sigma_individual;

array[N_individual] vector [N_gene] z_beta_individual;
array[N_condition] vector [N_gene] z_beta_condition;
array [N_individual] vector [N_gene] z_beta_individual;
array [N_condition] vector [N_gene] z_beta_condition;
}

transformed parameters {
array[N_individual] vector <lower=0, upper=1> [N_gene] theta;
array[N_individual] vector [N_gene] beta_individual;
array[N_condition] vector [N_gene] beta_condition;
array [N_individual] vector <lower=0, upper=1> [N_gene] theta;
array [N_individual] vector [N_gene] beta_individual;
array [N_condition] vector [N_gene] beta_condition;

for(i in 1:N_condition) {
beta_condition[i] = 0 + sigma_condition[i] * z_beta_condition[i];
Expand Down Expand Up @@ -98,16 +98,16 @@ model {

generated quantities {
// PPC: count usage (repertoire-level)
int Yhat_rep [N_gene, N_individual];
array [N_gene, N_individual] int Yhat_rep;

// PPC: proportion usage (repertoire-level)
real Yhat_rep_prop [N_gene, N_individual];
array [N_gene, N_individual] real Yhat_rep_prop;

// PPC: proportion usage at a gene level in condition
vector [N_gene] Yhat_condition_prop [N_condition];
array [N_condition] vector [N_gene] Yhat_condition_prop;

// LOG-LIK
vector [N_gene] log_lik [N_individual];
array [N_individual] vector [N_gene] log_lik;

// DGU matrix
matrix [N_gene, N_condition*(N_condition-1)/2] dgu;
Expand Down
32 changes: 16 additions & 16 deletions inst/stan/dgu_rep.stan
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ data {
int<lower=0> N_gene; // gene
int<lower=0> N_individual; // number of individuals
int<lower=0> N_condition; // number of conditions
array[N_sample] int N; // number of tries (repertoire size)
array[N_gene, N_sample] int Y; // number of heads for each coin
array[N_individual] int condition_id; // id of conditions
array[N_sample] int individual_id; // id of replicate
array [N_sample] int N; // number of tries (repertoire size)
array [N_gene, N_sample] int Y; // number of heads for each coin
array [N_individual] int condition_id; // id of conditions
array [N_sample] int individual_id; // id of replicate
}

transformed data {
// convert int N -> real N fo convenient division
// in generated quantities block
real Nr [N_sample];
array [N_sample] real Nr;
Nr = N;
}

Expand All @@ -55,17 +55,17 @@ parameters {
vector <lower=0> [N_condition] sigma_individual;
real <lower=0> sigma_replicate;

array[N_sample] vector [N_gene] z_beta_sample;
array[N_individual] vector [N_gene] z_beta_individual;
array[N_condition] vector [N_gene] z_beta_condition;
array [N_sample] vector [N_gene] z_beta_sample;
array [N_individual] vector [N_gene] z_beta_individual;
array [N_condition] vector [N_gene] z_beta_condition;
}


transformed parameters {
array[N_sample] vector <lower=0, upper=1> [N_gene] theta;
array[N_sample] vector [N_gene] beta_sample;
array[N_condition] vector [N_gene] beta_condition;
array[N_individual] vector [N_gene] beta_individual;
array [N_sample] vector <lower=0, upper=1> [N_gene] theta;
array [N_sample] vector [N_gene] beta_sample;
array [N_condition] vector [N_gene] beta_condition;
array [N_individual] vector [N_gene] beta_individual;

for(i in 1:N_condition) {
beta_condition[i] = 0 + sigma_condition[i] * z_beta_condition[i];
Expand Down Expand Up @@ -109,16 +109,16 @@ model {

generated quantities {
// PPC: count usage (repertoire-level)
int Yhat_rep [N_gene, N_sample];
array [N_gene, N_sample] int Yhat_rep;

// PPC: proportion usage (repertoire-level)
real Yhat_rep_prop [N_gene, N_sample];
array [N_gene, N_sample] real Yhat_rep_prop;

// PPC: proportion usage at a gene level in condition
vector [N_gene] Yhat_condition_prop [N_condition];
array [N_condition] vector [N_gene] Yhat_condition_prop;

// LOG-LIK
vector [N_gene] log_lik [N_sample];
array [N_sample] vector [N_gene] log_lik;

// DGU matrix
matrix [N_gene, N_condition*(N_condition-1)/2] dgu;
Expand Down
24 changes: 12 additions & 12 deletions inst/stan/gu.stan
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ data {
int<lower=0> N_gene; // gene
int<lower=0> N_individual; // number of individuals
int<lower=0> N_condition; // number of conditions
array[N_individual] int N; // number of tries (repertoire size)
array[N_gene, N_individual] int Y; // number of heads for each coin
array[N_individual] int condition_id; // id of conditions
array[N_individual] int individual_id; // id of replicate
array [N_individual] int N; // number of tries (repertoire size)
array [N_gene, N_individual] int Y; // number of heads for each coin
array [N_individual] int condition_id; // id of conditions
array [N_individual] int individual_id; // id of replicate
}

transformed data {
// convert int N -> real N fo convenient division
// in generated quantities block
real Nr [N_individual];
array [N_individual] real Nr;
Nr = N;
}

parameters {
real <lower=0> phi;
real <lower=0, upper=1> kappa;
real <lower=0> sigma_individual;
array[N_individual] vector [N_gene] z_beta_individual;
array [N_individual] vector [N_gene] z_beta_individual;
vector [N_gene] beta_condition;
}

transformed parameters {
array[N_individual] vector <lower=0, upper=1> [N_gene] theta;
array[N_individual] vector [N_gene] beta_sample;
array[N_individual] vector [N_gene] beta_individual;
array [N_individual] vector <lower=0, upper=1> [N_gene] theta;
array [N_individual] vector [N_gene] beta_sample;
array [N_individual] vector [N_gene] beta_individual;

for(i in 1:N_individual) {
beta_individual[i] = beta_condition + sigma_individual * z_beta_individual[i];
Expand Down Expand Up @@ -85,16 +85,16 @@ model {

generated quantities {
// PPC: count usage (repertoire-level)
int Yhat_rep [N_gene, N_individual];
array [N_gene, N_individual] int Yhat_rep;

// PPC: proportion usage (repertoire-level)
real Yhat_rep_prop [N_gene, N_individual];
array [N_gene, N_individual] real Yhat_rep_prop;

// PPC: proportion usage at a gene level in condition
vector [N_gene] Yhat_condition_prop;

// LOG-LIK
vector [N_gene] log_lik [N_individual];
array [N_individual] vector [N_gene] log_lik;

//TODO: speedup, run in C++ not big factor on performance
for(j in 1:N_gene) {
Expand Down
26 changes: 13 additions & 13 deletions inst/stan/gu_rep.stan
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ data {
int<lower=0> N_gene; // gene
int<lower=0> N_individual; // number of individuals
int<lower=0> N_condition; // number of conditions
array[N_sample] int N; // number of tries (repertoire size)
array[N_gene, N_sample] int Y; // number of heads for each coin
array[N_individual] int condition_id; // id of conditions
array[N_sample] int individual_id; // id of replicate
array [N_sample] int N; // number of tries (repertoire size)
array [N_gene, N_sample] int Y; // number of heads for each coin
array [N_individual] int condition_id; // id of conditions
array [N_sample] int individual_id; // id of replicate
}

transformed data {
// convert int N -> real N fo convenient division
// in generated quantities block
real Nr [N_sample];
array [N_sample] real Nr;
Nr = N;
}

Expand All @@ -52,17 +52,17 @@ parameters {
real <lower=0> sigma_individual;
real <lower=0> sigma_replicate;

array[N_sample] vector [N_gene] z_beta_sample;
array[N_individual] vector [N_gene] z_beta_individual;
array [N_sample] vector [N_gene] z_beta_sample;
array [N_individual] vector [N_gene] z_beta_individual;

vector [N_gene] beta_condition;
}


transformed parameters {
array[N_sample] vector <lower=0, upper=1> [N_gene] theta;
array[N_sample] vector [N_gene] beta_sample;
array[N_individual] vector [N_gene] beta_individual;
array [N_sample] vector <lower=0, upper=1> [N_gene] theta;
array [N_sample] vector [N_gene] beta_sample;
array [N_individual] vector [N_gene] beta_individual;

for(i in 1:N_individual) {
beta_individual[i] = beta_condition + sigma_individual * z_beta_individual[i];
Expand Down Expand Up @@ -98,16 +98,16 @@ model {

generated quantities {
// PPC: count usage (repertoire-level)
int Yhat_rep [N_gene, N_sample];
array [N_gene, N_sample] int Yhat_rep;

// PPC: proportion usage (repertoire-level)
real Yhat_rep_prop [N_gene, N_sample];
array [N_gene, N_sample] real Yhat_rep_prop;

// PPC: proportion usage at a gene level in condition
vector [N_gene] Yhat_condition_prop;

// LOG-LIK
vector [N_gene] log_lik [N_sample];
array [N_sample] vector [N_gene] log_lik;

//TODO: speedup, run in C++ not big factor on performance
for(j in 1:N_gene) {
Expand Down
6 changes: 3 additions & 3 deletions man/DGU.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ DGU(ud,
}

\arguments{
\item{ud}{Data.frame with 4 columns:
\item{ud}{Data.frame with 4 or 5 columns:
\itemize{
\item 'individual_id' = character, name of the donor (e.g. Pt1)
\item 'condition' = character, name of biological conditions (e.g. tumor)
\item 'gene_name' = character, Ig gene name (e.g. IGHV1-69)
\item 'gene_usage_count' = number, frequency (=usage) of rearrangements from
individual_id x condition x gene_name
\item [optional] 'repertoire' = character or number, if more than one
repertoire (biological replicates) is available per individual
\item [optional] 'replicate' = character or number. Replicate id, if more than
one repertoire (biological replicates) is available per individual
}
ud can also be be a SummarizedExperiment object. See examplary data
'data(Ig_SE)' for more information.
Expand Down
5 changes: 2 additions & 3 deletions man/LOO.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ LOO(ud,
\item 'gene_name' = character, Ig gene name (e.g. IGHV1-69)
\item 'gene_usage_count' = number, frequency (=usage) of rearrangements from
individual_id x condition x gene_name

\item [optional] 'repertoire' = character or number, if more than one
repertoire (biological replicates) is available per individual
\item [optional] 'replicate' = character or number. Replicate id, if more than
one repertoire (biological replicates) is available per individual
}
ud can also be be a SummarizedExperiment object. See dataset
'data(Ig_SE)' for more information.
Expand Down
Loading

0 comments on commit 8f96632

Please sign in to comment.