Skip to content

Commit

Permalink
Updata mirage.R fixing the bug for the re-index orignal group index t…
Browse files Browse the repository at this point in the history
…o new natural consecutive index
  • Loading branch information
XSun committed Apr 28, 2024
1 parent f8e7af4 commit 29762fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions R/mirage.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ mirage=function(data, n1, n2, gamma=3, sigma=2, eta.init=0.1, delta.init=0.1, es
if (ncol(data) == 4) data = cbind(seq(1, nrow(data)), data)
if (ncol(data) != 5) stop("Input data should have 4 or 5 columns!")
names(data) = c("ID", "Gene", "No.case", "No.contr", "category")
data=data[order(data$category, decreasing = F),]

################# re-index orignal group index to new natural consecutive index, 1, 2, 3,...
original.group.index=unique(data$category)
for (i in 1:length(original.group.index))
data[data$category==original.group.index[i],]$category=i
#################
# data=data[order(data$category, decreasing = F),]
#
# ################# re-index orignal group index to new natural consecutive index, 1, 2, 3,...
# original.group.index=unique(data$category)
# for (i in 1:length(original.group.index))
# data[data$category==original.group.index[i],]$category=i
# #################

data$category_factor <- factor(data$category, levels = unique(data$category))
data$category <- as.numeric(data$category_factor)
original.group.index <- as.character(data[!duplicated(data$category),]$category_factor)

gene.list=data$Gene
unique.gene = unique(gene.list)
Expand Down

0 comments on commit 29762fa

Please sign in to comment.