How to prevent background image from jumping on transition? - css

Is it possible to prevent background image from jumping effect when animation looping?
What i already tried:
Changing animation type from transition, to position change (left: 0 -> left: -100%)
Replacing background image to background gradient but result is the same
DEMO HERE
<button class="loader">
<span>Loader</span>
</button>
#keyframes sliding {
from {
transform: translateX(0%);
}
to {
transform: translateX(-50%);
}
}
body {
padding: 32px;
}
.loader {
width: 224px;
box-sizing: border-box;
padding: 14px;
border: none;
border-radius: 2px;
background-color: tomato;
position: relative;
overflow: hidden;
pointer-events: none;
}
.loader:after { content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: 200%;
height: 100%;
background-color: tomato;
background-image: url("data:image/svg+xml,%3Csvg width='210' height='59' viewBox='0 0 210 59' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='mask0' mask-type='alpha' maskUnits='userSpaceOnUse' x='0' y='0' width='210' height='59'%3E%3Crect width='210' height='59' fill='%23C4C4C4'/%3E%3C/mask%3E%3Cg mask='url(%23mask0)'%3E%3Cg opacity='0.3' filter='url(%23filter0_d)'%3E%3Cpath d='M-42 0H-18L32 59H8L-42 0Z' fill='white'/%3E%3C/g%3E%3Cg opacity='0.3' filter='url(%23filter1_d)'%3E%3Cpath d='M0 0H24L74 59H50L0 0Z' fill='white'/%3E%3C/g%3E%3Cg opacity='0.3' filter='url(%23filter2_d)'%3E%3Cpath d='M42 0H66L116 59H92L42 0Z' fill='white'/%3E%3C/g%3E%3Cg opacity='0.3' filter='url(%23filter3_d)'%3E%3Cpath d='M84 0H108L158 59H134L84 0Z' fill='white'/%3E%3C/g%3E%3Cg opacity='0.3' filter='url(%23filter4_d)'%3E%3Cpath d='M126 0H150L200 59H176L126 0Z' fill='white'/%3E%3C/g%3E%3Cg opacity='0.3' filter='url(%23filter5_d)'%3E%3Cpath d='M168 0H192L242 59H218L168 0Z' fill='white'/%3E%3C/g%3E%3C/g%3E%3Cdefs%3E%3Cfilter id='filter0_d' x='-46' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3Cfilter id='filter1_d' x='-4' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3Cfilter id='filter2_d' x='38' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3Cfilter id='filter3_d' x='80' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3Cfilter id='filter4_d' x='122' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3Cfilter id='filter5_d' x='164' y='-2' width='82' height='67' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0'/%3E%3CfeOffset dy='2'/%3E%3CfeGaussianBlur stdDeviation='2'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.07 0'/%3E%3CfeBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow'/%3E%3CfeBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow' result='shape'/%3E%3C/filter%3E%3C/defs%3E%3C/svg%3E%0A");
color: white;
background-repeat: repeat-x;
animation: sliding 1.75s linear infinite;
will-change: transform;
}
.loader span {
line-height: 20px;
font-size: 16px;
color: white;
}

As the background is repeated we can have this animation definition and can control the speed of the animation by setting 60-120s as per your requirement for the animation property.
#keyframes sliding {
from {
background-position: 0 0;
}
/*use negative width if you want it to flow right to left else and positive for left to right*/
to {
background-position: -10000px 0;
}
}

Related

SVG Icon Path Class in CSS

I'm embedding the following SVG icon as a path in my HTML page:
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>
How can I include the above SVG icon path as a class in CSS? So I can just use it as an attribute in my HTML page like this:
<i class="chevron-right"></i>
Update: With respect to the accepted answer, I had some problems getting the icon to vertically center properly and ended up finding a much simpler CSS code:
.chevron-right {
vertical-align: middle;
content: url("data:image/svg+xml, %3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill-rule='evenodd' d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}
Use it as background:
.chevron-right {
display: inline-block;
width: 1rem;
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>') 0 0/contain no-repeat;
}
.chevron-right::before {
content: "";
display: block;
padding-top: 100%;
}
<i class="chevron-right"></i>
<i class="chevron-right" style="width:2rem"></i>
<i class="chevron-right" style="width:4rem"></i>
In case you want coloration consider mask:
.chevron-right {
display: inline-block;
width: 1rem;
-webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>') 0 0/contain;
background: currentColor;
}
.chevron-right::before {
content: "";
display: block;
padding-top: 100%;
}
<i class="chevron-right"></i>
<i class="chevron-right" style="width:2rem;color:red;"></i>
<i class="chevron-right" style="width:4rem;color:blue;"></i>
Create a Custom Element: <svg-icon path="your d path"></svg-icon>
<style>
svg-icon svg {
width: 80px;
height:80px;
background: grey;
}
</style>
<svg-icon path="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"></svg-icon>
<script>
customElements.define("svg-icon", class extends HTMLElement {
connectedCallback() {
this.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="${this.getAttribute("path")}"/></svg>`;
}
});
</script>
If you need icons, see my pet-project IconMeister.github.io

Glowing animation on SVG using CSS

I am trying to apply glowing shadow effect on SVG icon but it does not work.
I have similar thing applied on text and that works fine using text-shadow:
.glow {
font-weight: 450;
-webkit-animation: glow 1.5s ease-in-out infinite alternate;
-moz-animation: glow 1.5s ease-in-out infinite alternate;
animation: glow 1.5s ease-in-out infinite alternate;
}
#-webkit-keyframes glow {
from {
text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #e60073, 0 0 20px #e60073,
0 0 25px #e60073, 0 0 30px #e60073, 0 0 35px #e60073;
}
to {
text-shadow: 0 0 10px #fff,
0 0 15px #ff9800 0 0 20px #ff9800 0 0 25px #ff9800 0 0 30px #ff9800 0 0
40px #ff9800 0 0 45px #ff4da6;
}
}
<a href="#sec1" class="nav-link glow">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="home" style="max-width:50px" class="svg-inline--fa fa-home fa-w-18 svg-shadow" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"></path></svg>
<span class="link-text">NASLOVNA</span>
</a>
So I tried same thing with SVG using webkit-filter: drop-shadow witch if you un-comment the line successfully drops shadow on SVG but I can not make it work to animate. I cant seem to find anywhere example of animation of SVG using shadow, i find some using fill but that does not interest me.
Any guidance is appreciated.
.svg-shadow {
/*-webkit-filter: drop-shadow( 3px 3px 2px #ff5722); */
-webkit-animation: svg-shadow 1.5s ease-in-out infinite alternate;
-moz-animation: svg-shadow 1.5s ease-in-out infinite alternate;
animation: svg-shadow 1.5s ease-in-out infinite alternate;
}
#-webkit-keyframes svg-shadow {
from {
-webkit-filter: drop-shadow( 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #e60073, 0 0 20px #e60073,
0 0 25px #e60073, 0 0 30px #e60073, 0 0 35px #e60073);
}
to {
-webkit-filter: drop-shadow( 0 0 10px #fff,
0 0 15px #ff9800 0 0 20px #ff9800 0 0 25px #ff9800 0 0 30px #ff9800 0 0
40px #ff9800 0 0 45px #ff4da6);
}
}
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="home" class="svg-inline--fa fa-home fa-w-18 svg-shadow" role="img" style="max-width:50px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"></path></svg>
Your syntax of multiple shadow is wrong, it need to be like below:
.svg-shadow {
animation: svg-shadow 1.5s ease-in-out infinite alternate;
}
#keyframes svg-shadow {
from {
filter: drop-shadow( 0 0 5px #fff) drop-shadow( 0 0 15px #e60073) drop-shadow( 0 0 20px #e60073);
}
to {
filter: drop-shadow( 0 0 20px #fff) drop-shadow( 0 0 25px #e60073) drop-shadow( 0 0 40px #e60073);
}
}
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="home" class="svg-inline--fa fa-home fa-w-18 svg-shadow" role="img" style="max-width:50px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"></path></svg>

Converting a single cell count matrix that is currently a text file into a data frame

I have downloaded some files off the internet that are single cell count matrices, and I want to convert them into dataframes in R. I have used readLines to read the text files in, but now each line of the file looks like this:
3110082J24Rik\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0
For some context, the columns in a single cell matrix file are the cells, and the rows are the genes. The numbers in the file indicate the number of times that the gene (for this line, 3110082J24Rik) appears in each cell. Anyone have any idea how I could do this? Here is some sample data:
ID W308561 W308562 W308563 W308564 W308565 W308566 W308567 W308568 W308569 W308570 W308571 W308572 W308573 W308574 W308575 W308576 W308577 W308578 W308579 W308580 W308581 W308582 W308583 W308584 W308585 W308586 W308587 W308588 W308589 W308590 W308591 W308592 W308593 W308594 W308595 W308596 W308597 W308598 W308599 W308600 W308601 W308602 W308603 W308604 W308605 W308606 W308607 W308608 W308609 W308610 W308611 W308612 W308613 W308614 W308615 W308616 W308617 W308618 W308619 W308620 W308621 W308622 W308623 W308624 W308625 W308626 W308627 W308628 W308629 W308630 W308631 W308632 W308633 W308634 W308635 W308636 W308637 W308638 W308639 W308640 W308641 W308642 W308643 W308644 W308645 W308646 W308647 W308648 W308649 W308650 W308651 W308652 W308653 W308654 W308655 W308656 W308657 W308658 W308659 W308660 W308661 W308662 W308663 W308664 W308665 W308666 W308667 W308668 W308669 W308670 W308671 W308672 W308673 W308674 W308675 W308676 W308677 W308678 W308679 W308680 W308681 W308682 W308683 W308684 W308685 W308686 W308687 W308688 W308689 W308690 W308691 W308692 W308693 W308694 W308695 W308696 W308697 W308698 W308699 W308700 W308701 W308702 W308703 W308704 W308705 W308706 W308707 W308708 W308709 W308710 W308711 W308712 W308713 W308714 W308715 W308716 W308717 W308718 W308719 W308720 W308721 W308722 W308723 W308724 W308725 W308726 W308727 W308728 W308729 W308730 W308731 W308732 W308733 W308734 W308735 W308736 W308737 W308738 W308739 W308740 W308741 W308742 W308743 W308744 W308745 W308746 W308747 W308748 W308749 W308750 W308751 W308752 W308753 W308754 W308755 W308756 W308757 W308758 W308759 W308760 W308761 W308762 W308763 W308764 W308765 W308766 W308767 W308768 W308769 W308770 W308771 W308772 W308773 W308774 W308775 W308776 W308777 W308778 W308779 W308780 W308781 W308782 W308783 W308784 W308785 W308786 W308787 W308788 W308789 W308790 W308791 W308792 W308793 W308794 W308795 W308796 W308797 W308798 W308799 W308800 W308801 W308802 W308803 W308804 W308805 W308806 W308807 W308808 W308809 W308810 W308811 W308812 W308813 W308814 W308815 W308816 W308817 W308818 W308819 W308820 W308821 W308822 W308823 W308824 W308825 W308826 W308827 W308828 W308829 W308830 W308831 W308832 W308833 W308834 W308835 W308836 W308837 W308838 W308839 W308840 W308841 W308842 W308843 W308844 W308845 W308846 W308847 W308848 W308849 W308850 W308851 W308852 W308853 W308854 W308855 W308856 W308857 W308858 W308859 W308860 W308861 W308862 W308863 W308864 W308865 W308866 W308867 W308868 W308869 W308870 W308871 W308872 W308873 W308874 W308875 W308876 W308877 W308878 W308879 W308880 W308881 W308882 W308883 W308884 W308885 W308886 W308887 W308888 W308889 W308890 W308891 W308892 W308893 W308894 W308895 W308896 W308897 W308898 W308899 W308900 W308901 W308902 W308903 W308904 W308905 W308906 W308907 W308908 W308909 W308910 W308911 W308912 W308913 W308914 W308915 W308916 W308917 W308918 W308919 W308920 W308921 W308922 W308923 W308924 W308925 W308926 W308927 W308928 W308929 W308930 W308931 W308932 W308933 W308934 W308935 W308936 W308937 W308938 W308939 W308940 W308941 W308942 W308943 W308944
0610005C13Rik 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0610007C21Rik 0 3 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In the ideal world, each of the labels at the top that starts with "W" would be a separate column with the corresponding numbers for each gene also in that column.

Comparison of two dataframes

I have an excel table of 15200 lines, corresponding to a tree analyzed for its structures. I have all the structures in columns (48 structures), they have been counted on every tree. for example, the tree 12607 has 3 structures CV11, 1 structure IN12 and none (0) of the rest of all the structures. Thus, the table looks like a huge table with a lot of 0 and some numbers of the occurrence of structures on the trees. The very last column is the value given to the tree, according to the structures found on it (each structure giving a number of point to the tree by its presence on it).
The question is: Are there some structures, or combination of structures, which give a high value to the tree. Of course, according to the value of each structure, we can see which one has a higher value than the others (ex: structure CV11 has a value of 15, structure IN12 has a value of 4). But what I want to know is, if we take all the trees having a higher final value than 100 (we create a new dataframe "data100"), and we compare with the trees having a final value under 100 (we create another dataframe "data0"), can we find a significant difference in the number and occurrence of structures found on these trees? Because the structure with high value is maybe only found on the trees with a value under 100; because for example, this structure does not allow other structures to be found on the same tree.
VoilĂ , I hope I have given enough details... If you have any idea or proposition for solving this problem.. it will be great!
Below is my script.
> data100
CV11 CV12 CV13 CV14 CV15 CV21 CV22 CV23 CV24 CV25 CV26 CV31 CV32 CV33 CV41 CV42 CV43 CV44 CV51 CV52 IN11 IN12 IN13
1 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 77
14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54
15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20
[ reached getOption("max.print") -- omitted 60749 rows ]
> sortdata100<-data100[order(data100[,64],decreasing=T),]
> rsortdata100<-sortdata100[sortdata100$ecoval>100,]
> rsortdata100<-na.omit(rsortdata100)#181 lignes
> rsortdata100
CV11 CV12 CV13 CV14 CV15 CV21 CV22 CV23 CV24 CV25 CV26 CV31 CV32 CV33 CV41 CV42 CV43 CV44 CV51 CV52 IN11 IN12 IN13
1291 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1083 0 4 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3919 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0
14685 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
4021 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
5452 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
14686 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0
4022 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0
1013 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2895 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4719 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
682 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
3444 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1299 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
2713 0 0 0 4 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 380
14685 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 370
4021 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 358
5452 0 0 0 0 0 0 1 0 0 11 0 0 0 0 1 0 0 356
14686 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 354
4022 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 346
1013 0 8 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 326
2895 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 325
4719 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 324
682 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 311
3444 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 306
1299 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 302
2713 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 302
[ reached getOption("max.print") -- omitted 166 rows ]
> data0<-sortdata100[sortdata100$ecoval<100,]
> data0<-na.omit(data0)
> data0
CV11 CV12 CV13 CV14 CV15 CV21 CV22 CV23 CV24 CV25 CV26 CV31 CV32 CV33 CV41 CV42 CV43 CV44 CV51 CV52 IN11 IN12 IN13
4728 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
5339 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
11766 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
796 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3561 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
10581 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
10618 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0
14376 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0
156 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 6 2 0 0 0 0 0 0 0 0
2950 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EP11 EP12 EP13 EP14 EP21 EP31 EP32 EP33 EP34 EP35 NE11 NE12 NE21 OT11 OT12 OT21 OT22 ecoval
4728 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 99
5339 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 99
11766 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 99
796 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98
3561 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98
10581 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 98
10618 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 98
14376 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98
14389 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98
790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 97
3974 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 97
4739 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 1 0 97
156 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 96
2950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96
[ reached getOption("max.print") -- omitted 14984 rows ]
maybe something like this ?
library(dplyr)
data %>% group_by(ecoval > 100) %>% summarize_all(mean)
that should give you the average of each column for ecoval > and <= to 100

Handle error with try in R

I am trying to make function that returns geometric mean with data.
I want to make loop with try() to pass valid data, but what i tried actually didn't worked.
This is function
R=function(g)
{
k=1
n=length(g)
for(i in 1 : n)
{
ifelse(g[i]>0, k<-k*g[i], stop("Negative component"))
k
}
t=k^(1/n)
t
}
And i want to use this function in this loop
set.seed(123)
data <- matrix(rnorm(10000, mean=3), ncol=25, dimnames=list(NULL, paste("X",
1:25, sep=".")))
v=rep(0,400)
for(i in 1 : 400)
{
try("v[i]=R(data[,i])",TRUE)
}
v
I want to get means for valid data, but it makes all value to 0
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[37] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[73] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[109] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[145] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[181] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[217] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[253] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[289] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[325] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[361] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[397] 0 0 0 0
Can you let me know where was wrong??
Thanks
I guess the problem is with the missing declaration of t as a numeric vector and the syntax of try() function. The following code should work, it worked for me.
R=function(g)
{
t = numeric(length(g))
k=1
n=length(g)
for(i in 1 : n)
{
ifelse(g[i]>0, k<-k*g[i], stop("Negative component"))
}
t=k^(1/n)
t
}
set.seed(123)
data <- matrix(rnorm(10000, mean=3), ncol=25, dimnames=list(NULL,paste("X",
1:25, sep=".")))
v=numeric(400)
for(i in 1 : 400)
{
try(v[i]<-R(data[i,]),TRUE)
}
v

Resources