Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vihgo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gad-public
vihgo
Commits
8f142c83
Commit
8f142c83
authored
Jul 29, 2020
by
Yannis Duffourd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing new method to FET computing, not in used actually
parent
4f1e74c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
2 deletions
+111
-2
utils.cpp
cpp/utils.cpp
+106
-0
utils.h
cpp/utils.h
+5
-2
No files found.
cpp/utils.cpp
View file @
8f142c83
...
@@ -214,3 +214,109 @@ char checkBase(char incoming )
...
@@ -214,3 +214,109 @@ char checkBase(char incoming )
}
}
return
'N'
;
return
'N'
;
}
}
//Method for calculating a sd from a vector of double
double
sd_calculator
(
vector
<
double
>
incVector
)
{
// Déclarations
double
sd
;
double
temp_value
;
double
sumone
=
0
;
double
sumtwo
=
0
;
double
moyenne
;
int
number
=
0
;
double
variance
;
// calcul des moyennes et moyennes carrées
vector
<
double
>::
iterator
myIter
;
for
(
myIter
=
incVector
.
begin
()
;
myIter
!=
incVector
.
end
()
;
myIter
++
)
{
temp_value
=
*
myIter
;
sumone
+=
temp_value
;
sumtwo
+=
(
temp_value
*
temp_value
);
number
++
;
}
// calcul de la moyenne
moyenne
=
sumone
/
number
;
// Calcul de la variance
variance
=
(
sumtwo
/
number
)
-
(
moyenne
*
moyenne
);
// Calcul ecart type
sd
=
sqrt
(
variance
);
return
sd
;
}
// Method for calculating a mean from a vector of double
double
moyenne_calculator
(
vector
<
double
>
incVector
)
{
// Déclarations
double
temp_value
;
double
sumone
;
double
moyenne
;
int
number
=
0
;
// calcul des moyennes et moyennes carrées
vector
<
double
>::
iterator
myIter
;
for
(
myIter
=
incVector
.
begin
()
;
myIter
!=
incVector
.
end
()
;
myIter
++
)
{
temp_value
=
*
myIter
;
sumone
+=
temp_value
;
number
++
;
}
// calcul de la moyenne
if
(
number
!=
0
)
{
moyenne
=
sumone
/
number
;
}
else
{
return
0
;
}
return
moyenne
;
}
// Method for calculating fisher exact test 2-sided, return the pvalue.
double
FET
(
int
a
,
int
b
,
int
c
,
int
d
)
{
int
n
=
a
+
b
+
c
+
d
;
double
logpCutOff
=
logHypergeometricProb
(
a
,
b
,
c
,
d
);
double
pFraction
=
0
;
double
logpValue
=
0
;
for
(
int
x
=
0
;
x
<=
n
;
x
++
)
{
if
(
(
a
+
b
-
x
>=
0
)
&&
(
a
+
c
-
x
>=
0
)
&&
(
d
-
a
+
x
>=
0
)
)
{
double
l
=
logHypergeometricProb
(
x
,
a
+
b
-
x
,
a
+
c
-
x
,
d
-
a
+
x
);
if
(
l
<=
logpCutOff
)
{
pFraction
+=
exp
(
l
-
logpCutOff
);
}
}
}
logpValue
=
logpCutOff
+
log
(
pFraction
);
return
exp
(
logpValue
);
}
// method for calculating the hypergeometrical log value for the FET.
double
logHypergeometricProb
(
int
a
,
int
b
,
int
c
,
int
d
)
{
return
logFactoriel
(
a
+
b
)
+
logFactoriel
(
c
+
d
)
+
logFactoriel
(
a
+
c
)
+
logFactoriel
(
b
+
d
)
-
logFactoriel
(
a
)
-
logFactoriel
(
b
)
-
logFactoriel
(
c
)
-
logFactoriel
(
d
)
-
logFactoriel
(
a
+
b
+
c
+
d
);
}
// Method for calculating a log factoriel
double
logFactoriel
(
int
inc
)
{
double
ret
;
for
(
ret
=
0
;
inc
>
0
;
inc
--
)
{
ret
+=
log
(
(
double
)
inc
);
}
return
ret
;
}
cpp/utils.h
View file @
8f142c83
...
@@ -17,7 +17,10 @@ char string_to_char( std::string );
...
@@ -17,7 +17,10 @@ char string_to_char( std::string );
std
::
string
strip
(
std
::
string
);
std
::
string
strip
(
std
::
string
);
double
chisquare
(
std
::
vector
<
double
>
,
std
::
vector
<
double
>
);
double
chisquare
(
std
::
vector
<
double
>
,
std
::
vector
<
double
>
);
double
fisher_test
(
std
::
vector
<
double
>
,
std
::
vector
<
double
>
);
double
fisher_test
(
std
::
vector
<
double
>
,
std
::
vector
<
double
>
);
double
sd_calculator
(
std
::
vector
<
double
>
);
double
moyenne_calculator
(
std
::
vector
<
double
>
);
double
FET
(
int
,
int
,
int
,
int
);
double
logHypergeometricProb
(
int
,
int
,
int
,
int
);
double
logFactoriel
(
int
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment