Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HIDDEN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sPlot
HIDDEN
Commits
a1b4c84c
Commit
a1b4c84c
authored
4 years ago
by
Francesco Sabatini
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug in 00 and cleaned and renamed traits
parent
90679f2b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
00_Mesobromion_DataPreparation.R
+34
-10
34 additions, 10 deletions
00_Mesobromion_DataPreparation.R
with
34 additions
and
10 deletions
00_Mesobromion_DataPreparation.R
+
34
−
10
View file @
a1b4c84c
...
...
@@ -144,18 +144,18 @@ dim(species) # [1] 5810 873
releve08trait
<-
species
%>%
rownames_to_column
(
"RELEVE_NR"
)
%>%
reshape2
::
melt
(
.id
=
"RELEVE_NR"
)
%>%
rename
(
species0
=
variable
,
p
res
=
value
)
%>%
rename
(
species0
=
variable
,
p
erc.cover
=
value
)
%>%
as.tbl
()
%>%
filter
(
p
res
>
0
)
%>%
filter
(
p
erc.cover
>
0
)
%>%
arrange
(
RELEVE_NR
)
%>%
## attach traits
left_join
(
traits
%>%
dplyr
::
select
(
-
species
),
by
=
"species0"
)
%>%
mutate_at
(
.vars
=
vars
(
LEB_F_Makrophanerophyt
:
Disp.unit.leng
),
.funs
=
list
(
~
if_else
(
is.na
(
.
),
0
,
1
)
*
p
res
))
%>%
.funs
=
list
(
~
if_else
(
is.na
(
.
),
0
,
1
)
*
p
erc.cover
))
%>%
group_by
(
RELEVE_NR
)
%>%
summarize_at
(
.vars
=
vars
(
LEB_F_Makrophanerophyt
:
Disp.unit.leng
),
.funs
=
list
(
~
mean
(
.
)))
%>%
.funs
=
list
(
~
sum
(
.
)
/
sum
(
perc.cover
)))
%>%
dplyr
::
select
(
RELEVE_NR
,
order
(
colnames
(
.
)))
%>%
reshape2
::
melt
(
id.vars
=
"RELEVE_NR"
,
value.name
=
"trait.coverage"
)
%>%
group_by
(
RELEVE_NR
)
%>%
...
...
@@ -163,6 +163,7 @@ releve08trait <- species %>%
#select only those releves where we have a coverage of >0.8 for all traits
filter
(
ntraits08
==
1
)
%>%
pull
(
RELEVE_NR
)
length
(
releve08trait
)
#[1] 5646
set.seed
(
1984
)
releve08trait.samp
<-
sample
(
releve08trait
,
round
(
length
(
releve08trait
)
/
10
),
replace
=
F
)
...
...
@@ -253,14 +254,36 @@ recode.traits <- function(x){
}
traits
<-
recode.traits
(
traits
)
### Some cleaning and renaming of traits; exclude CSR - decisions 25.08.2020
traits
<-
traits
%>%
dplyr
::
select
(
-
STRAT_T
)
%>%
mutate
(
REPR_T
=
factor
(
REPR_T
,
levels
=
c
(
"Samen_Sporen"
,
"vegetativ"
),
labels
=
c
(
"Seed/Spores"
,
"Vegetative"
)))
%>%
mutate
(
BLU_KL
=
factor
(
BLU_KL
,
levels
=
c
(
"NEKTAR_HONIG_INSEKTEN"
,
"POLLEN"
,
"WIND"
),
labels
=
c
(
"Nectar/Honey/Insects"
,
"Pollen"
,
"Wind"
)))
%>%
mutate
(
BL_AUSD
=
factor
(
BL_AUSD
,
levels
=
c
(
"immergrün"
,
"sommergrün"
,
"überwinternd_grün"
,
"vorsommergrün"
),
labels
=
c
(
"eg"
,
"sg"
,
"wg"
,
"se"
)))
##rename traits based on labels
trait.labs
<-
data.frame
(
trait.name
=
colnames
(
traits
)[
-1
])
%>%
left_join
(
read_delim
(
"_data/Mesobromion/TraitLabels_Long.csv"
,
delim
=
","
),
by
=
"trait.name"
)
%>%
rownames_to_column
(
"Trait.comb"
)
%>%
mutate_at
(
.vars
=
vars
(
Short_english_name
:
Long_English_name
),
~
ifelse
(
is.na
(
.
),
trait.name
,
{
.
}))
%>%
filter
(
trait.name
%in%
colnames
(
traits
))
traits
<-
traits
%>%
rename_at
(
trait.labs
$
trait.name
,
.funs
=
function
(
x
)
trait.labs
$
Short_english_name
)
##exclude traits being all == 0
traits
<-
traits
%>%
dplyr
::
select
(
-
colnames
(
.
)[
which
(
colSums
(
.
!=
0
)
==
0
)])
dplyr
::
select
(
-
colnames
(
.
)[
which
(
colSums
(
.
!=
0
)
==
0
)])
dim
(
species
)
#5
81 509
dim
(
traits
)
#
509 49
dim
(
env
)
#5
81
8
dim
(
species
)
#5
65 488
dim
(
traits
)
#
488 50
dim
(
env
)
#5
65
8
...
...
@@ -319,9 +342,10 @@ species.cov <- species.cov %>%
mutate_at
(
.vars
=
vars
(
-
RELEVE_NR
),
.funs
=~
.
/
sumVar
)
%>%
dplyr
::
select
(
-
sumVar
)
dim
(
species.cov
)
#[1] 5
81 510
dim
(
species.cov
)
#[1] 5
65 489
## export
write_delim
(
species
,
path
=
"_data/Mesobromion/species.v2.10perc.percentage.txt"
,
delim
=
"\t"
)
## original covere values
write_delim
(
species.pa
,
path
=
"_data/Mesobromion/species.v2.10perc.pa.txt"
,
delim
=
"\t"
)
write_delim
(
species.cov
,
path
=
"_data/Mesobromion/species.v2.10perc.cov.txt"
,
delim
=
"\t"
)
write_delim
(
traits
,
path
=
"_data/Mesobromion/traits.v2.10perc.txt"
,
delim
=
"\t"
)
...
...
@@ -342,7 +366,7 @@ traits %>%
traits
%>%
filter_at
(
.vars
=
vars
(
-
"species0"
),
any_vars
(
is.na
(
.
)))
%>%
nrow
()
## [1]
36
# species with at least 1 NA in traits
nrow
()
## [1]
47
# species with at least 1 NA in traits
#### CORRELATION BETWEEN FUZZY WEIGHTED AND BEALS MATRICES
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment